当前位置: 首页>>代码示例>>C#>>正文


C# Zip.ZipInputStream类代码示例

本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.ZipInputStream的典型用法代码示例。如果您正苦于以下问题:C# ZipInputStream类的具体用法?C# ZipInputStream怎么用?C# ZipInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ZipInputStream类属于ICSharpCode.SharpZipLib.Zip命名空间,在下文中一共展示了ZipInputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Decompress

        public bool Decompress()
        {
            Boolean gotIt = false;
            using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipFilePath)))
            {
                ZipEntry theEntry;
                while ((theEntry = s.GetNextEntry()) != null)
                {
                    if (theEntry.IsFile && theEntry.Name == m_msi)
                    {
                        gotIt = true;
                        FileStream streamWriter = File.Create(msiFilePath);
                        long filesize = theEntry.Size;
                        byte[] data = new byte[filesize];
                        while (true)
                        {
                            filesize = s.Read(data, 0, data.Length);
                            if (filesize > 0)
                            {
                                streamWriter.Write(data, 0, (int)filesize);
                            }
                            else
                            {
                                break;
                            }
                        }
                        streamWriter.Close();
                    }
                }
            }

            return gotIt;
        }
开发者ID:ChrisPea,项目名称:TuningSuites,代码行数:33,代码来源:zipmsiupdater.cs

示例2: GetDefinitionStreamsFromBundle

        public static void GetDefinitionStreamsFromBundle(string bundlePath, out Stream monoTodoDefinitions, out Stream notImplementedDefinitions, out Stream missingDefinitions)
        {
            ZipInputStream zs = new ZipInputStream (File.OpenRead (bundlePath));
            ZipEntry ze;

            monoTodoDefinitions = null;
            notImplementedDefinitions = null;
            missingDefinitions = null;

            while ((ze = zs.GetNextEntry ()) != null) {
                switch (ze.Name) {
                    case "monotodo.txt":
                        StreamReader sr = new StreamReader (zs);
                        string s = sr.ReadToEnd ();
                        monoTodoDefinitions = new MemoryStream (ASCIIEncoding.ASCII.GetBytes (s));
                        break;
                    case "exception.txt":
                        StreamReader sr2 = new StreamReader (zs);
                        string s2 = sr2.ReadToEnd ();
                        notImplementedDefinitions = new MemoryStream (ASCIIEncoding.ASCII.GetBytes (s2));
                        break;
                    case "missing.txt":
                        StreamReader sr3 = new StreamReader (zs);
                        string s3 = sr3.ReadToEnd ();
                        missingDefinitions = new MemoryStream (ASCIIEncoding.ASCII.GetBytes (s3));
                        break;
                    default:
                        break;
                }
            }
        }
开发者ID:robertpi,项目名称:moma,代码行数:31,代码来源:DefinitionHandler.cs

示例3: ReadInMemory

 public static void ReadInMemory(FileInfo zipFileName, Predicate<ZipEntry> filter, Action<MemoryStream> action)
 {
     using (ZipInputStream inputStream = new ZipInputStream(zipFileName.OpenRead()))
     {
         ZipEntry entry;
         while ((entry = inputStream.GetNextEntry()) != null)
         {
             if (filter(entry))
             {
                 using (MemoryStream stream = new MemoryStream())
                 {
                     int count = 0x800;
                     byte[] buffer = new byte[0x800];
                     if (entry.Size <= 0L)
                     {
                         goto Label_0138;
                     }
                 Label_0116:
                     count = inputStream.Read(buffer, 0, buffer.Length);
                     if (count > 0)
                     {
                         stream.Write(buffer, 0, count);
                         goto Label_0116;
                     }
                 Label_0138:
                     stream.Position = 0;
                     action(stream);
                 }
             }
         }
     }
 }
开发者ID:julienblin,项目名称:NAntConsole,代码行数:32,代码来源:ZipHelper.cs

示例4: ImportMethod

        protected override void ImportMethod()
        {
            using (Utils.ProgressBlock progress = new Utils.ProgressBlock(this, STR_IMPORT, STR_DOWNLOAD, 1, 0))
            {
                using (System.IO.TemporaryFile tmp = new System.IO.TemporaryFile(true))
                using (System.Net.WebClient wc = new System.Net.WebClient())
                {
                    wc.DownloadFile("http://www.globalcaching.eu/service/cachedistance.aspx?country=Netherlands&prefix=GC", tmp.Path);

                    using (var fs = System.IO.File.OpenRead(tmp.Path))
                    using (ZipInputStream s = new ZipInputStream(fs))
                    {
                        ZipEntry theEntry = s.GetNextEntry();
                        byte[] data = new byte[1024];
                        if (theEntry != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            while (true)
                            {
                                int size = s.Read(data, 0, data.Length);
                                if (size > 0)
                                {
                                    if (sb.Length == 0 && data[0] == 0xEF && size > 2)
                                    {
                                        sb.Append(System.Text.ASCIIEncoding.UTF8.GetString(data, 3, size - 3));
                                    }
                                    else
                                    {
                                        sb.Append(System.Text.ASCIIEncoding.UTF8.GetString(data, 0, size));
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }

                            XmlDocument doc = new XmlDocument();
                            doc.LoadXml(sb.ToString());
                            XmlElement root = doc.DocumentElement;
                            XmlNodeList nl = root.SelectNodes("wp");
                            if (nl != null)
                            {
                                Core.Geocaches.AddCustomAttribute(CUSTOM_ATTRIBUTE);
                                foreach (XmlNode n in nl)
                                {
                                    var gc = Utils.DataAccess.GetGeocache(Core.Geocaches, n.Attributes["code"].InnerText);
                                    if (gc != null)
                                    {
                                        string dist = Utils.Conversion.StringToDouble(n.Attributes["dist"].InnerText).ToString("000.0");
                                        gc.SetCustomAttribute(CUSTOM_ATTRIBUTE, dist);
                                    }
                                }
                            }
                        }
                    }

                }
            }
        }
开发者ID:RH-Code,项目名称:GAPP,代码行数:60,代码来源:GeocacheDistance.cs

示例5: ImportTranslatedLists

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Import a file containing translations for one or more lists.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool ImportTranslatedLists(string filename, FdoCache cache, IProgress progress)
		{
#if DEBUG
			DateTime dtBegin = DateTime.Now;
#endif
			using (var inputStream = FileUtils.OpenStreamForRead(filename))
			{
				var type = Path.GetExtension(filename).ToLowerInvariant();
				if (type == ".zip")
				{
					using (var zipStream = new ZipInputStream(inputStream))
					{
						var entry = zipStream.GetNextEntry(); // advances it to where we can read the one zipped file.
						using (var reader = new StreamReader(zipStream, Encoding.UTF8))
							ImportTranslatedLists(reader, cache, progress);
					}
				}
				else
				{
					using (var reader = new StreamReader(inputStream, Encoding.UTF8))
						ImportTranslatedLists(reader, cache, progress);
				}
			}
#if DEBUG
			DateTime dtEnd = DateTime.Now;
			TimeSpan span = new TimeSpan(dtEnd.Ticks - dtBegin.Ticks);
			Debug.WriteLine(String.Format("Elapsed time for loading translated list(s) from {0} = {1}",
				filename, span.ToString()));
#endif
			return true;
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:36,代码来源:XmlTranslatedLists.cs

示例6: UnZip

        public static void UnZip(byte[] inputZipBinary, string destinationPath)
        {
            DirectoryInfo outDirInfo = new DirectoryInfo(destinationPath);
            if (!outDirInfo.Exists)
                outDirInfo.Create();

            using (MemoryStream msZipBinary = new MemoryStream(inputZipBinary))
            {
                using (ZipInputStream zipFile = new ZipInputStream(msZipBinary))
                {
                    ZipEntry zipEntry;
                    while ((zipEntry = zipFile.GetNextEntry()) != null)
                    {
                        FileStream fsOut = File.Create(outDirInfo.FullName + "\\" + zipEntry.Name);
                        byte[] buffer = new byte[4096]; int count = 0;

            #if DEBUG
                        Console.WriteLine("Descomprimiendo: " + zipEntry.Name +
                            " |Tamaño comprimido: " + zipEntry.CompressedSize +
                            " |Tamano descomprimido: " + zipEntry.Size +
                            " |CRC: " + zipEntry.Crc);
            #endif

                        while ((count = zipFile.Read(buffer, 0, buffer.Length)) > 0)
                            fsOut.Write(buffer, 0, count);
                        fsOut.Flush();
                        fsOut.Close();
                    }
                }
            }
        }
开发者ID:sergiosorias,项目名称:terminalzero,代码行数:31,代码来源:SharpZipLib.cs

示例7: ExtractZipFile

 public static void ExtractZipFile(string zipFileName, string dirName)
 {
     var data = new byte[readBufferSize];
     using (var zipStream = new ZipInputStream(File.OpenRead(zipFileName)))
     {
         ZipEntry entry;
         while ((entry = zipStream.GetNextEntry()) != null)
         {
             var fullName = Path.Combine(dirName, entry.Name);
             if (entry.IsDirectory && !Directory.Exists(fullName))
             {
                 Directory.CreateDirectory(fullName);
             }
             else if (entry.IsFile)
             {
                 var dir = Path.GetDirectoryName(fullName);
                 if (!Directory.Exists(dir))
                 {
                     Directory.CreateDirectory(dir);
                 }
                 using (var fileStream = File.Create(fullName))
                 {
                     int readed;
                     while ((readed = zipStream.Read(data, 0, readBufferSize)) > 0)
                     {
                         fileStream.Write(data, 0, readed);
                     }
                 }
             }
         }
     }
 }
开发者ID:supermuk,项目名称:iudico,代码行数:32,代码来源:Zipper.cs

示例8: Main

	public static void Main(string[] args)
	{
		ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
		
		ZipEntry theEntry;
		while ((theEntry = s.GetNextEntry()) != null) {
			
			Console.WriteLine(theEntry.Name);
			
			string directoryName = Path.GetDirectoryName(theEntry.Name);
			string fileName      = Path.GetFileName(theEntry.Name);
			
			// create directory
			Directory.CreateDirectory(directoryName);
			
			if (fileName != String.Empty) {
				FileStream streamWriter = File.Create(theEntry.Name);
				
				int size = 2048;
				byte[] data = new byte[2048];
				while (true) {
					size = s.Read(data, 0, data.Length);
					if (size > 0) {
						streamWriter.Write(data, 0, size);
					} else {
						break;
					}
				}
				
				streamWriter.Close();
			}
		}
		s.Close();
	}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:34,代码来源:UnZipFile.cs

示例9: Unzip

        // 압축을 해제한다.
        private void Unzip(string zipfile)
        {
            // 풀고자 하는 압축 파일 이름
            ZipInputStream s = new ZipInputStream(File.OpenRead(zipfile));

            ZipEntry theEntry;
            while ((theEntry = s.GetNextEntry()) != null)
            {
                // 압축을 풀고자 하는 대상 폴더 이름이 "C:\test" 인 경우
                string fullname = @"C:\zipTest" + theEntry.Name;

                string directoryName = Path.GetDirectoryName(fullname);
                string fileName = Path.GetFileName(fullname);

                if (!Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName);

                if (fileName != String.Empty)
                {
                    FileStream streamWriter = File.Create(fullname);
                    int size = 2048;
                    byte[] data = new byte[2048];
                    while (true)
                    {
                        size = s.Read(data, 0, data.Length);
                        if (size > 0) streamWriter.Write(data, 0, size);
                        else break;
                    }
                    streamWriter.Close();
                }
            }
            s.Close();
        }
开发者ID:sunnamkim,项目名称:doc,代码行数:33,代码来源:WebForm1.aspx.cs

示例10: ZipExtractor

        /// <summary>
        /// Prepares to extract a ZIP archive contained in a stream.
        /// </summary>
        /// <param name="stream">The stream containing the archive data to be extracted. Will be disposed when the extractor is disposed.</param>
        /// <param name="target">The path to the directory to extract into.</param>
        /// <exception cref="IOException">The archive is damaged.</exception>
        internal ZipExtractor([NotNull] Stream stream, [NotNull] string target)
            : base(target)
        {
            #region Sanity checks
            if (stream == null) throw new ArgumentNullException("stream");
            #endregion

            UnitsTotal = stream.Length;

            try
            {
                // Read the central directory
                using (var zipFile = new ZipFile(stream) {IsStreamOwner = false})
                {
                    _centralDirectory = new ZipEntry[zipFile.Count];
                    for (int i = 0; i < _centralDirectory.Length; i++)
                        _centralDirectory[i] = zipFile[i];
                }
                stream.Seek(0, SeekOrigin.Begin);

                _zipStream = new ZipInputStream(stream);
            }
                #region Error handling
            catch (ZipException ex)
            {
                // Wrap exception since only certain exception types are allowed
                throw new IOException(Resources.ArchiveInvalid, ex);
            }
            #endregion
        }
开发者ID:modulexcite,项目名称:0install-win,代码行数:36,代码来源:ZipExtractor.cs

示例11: Add

        public override void Add (string path)
        {
            using (var file_stream = new FileStream (path, FileMode.Open, FileAccess.Read))
            using (var zip_stream = new ZipInputStream (file_stream)) {                
                ZipEntry entry;
                while ((entry = zip_stream.GetNextEntry ()) != null) {
                    if (!entry.IsFile) {
                        continue;
                    }
                    var extension = Path.GetExtension (entry.Name);
                    if (!parser_for_parts.SupportedFileExtensions.Contains (extension)) {
                        continue;
                    }

                    using (var out_stream = new MemoryStream ()) {
                        int size;
                        var buffer = new byte[2048];
                        do {
                            size = zip_stream.Read (buffer, 0, buffer.Length);
                            out_stream.Write (buffer, 0, size);
                        } while (size > 0);

                        out_stream.Seek (0, SeekOrigin.Begin);
                        try {
                            parser_for_parts.Add (out_stream, entry.Name);
                        } catch (NotSupportedException) {
                            
                        }
                    }
                }                
            }
        }
开发者ID:lothrop,项目名称:vernacular,代码行数:32,代码来源:XapParser.cs

示例12: GetIpaPList

        private static Dictionary<string, object> GetIpaPList(string filePath)
        {
            var plist = new Dictionary<string, object>();
            var zip = new ZipInputStream(File.OpenRead(filePath));
            using (var filestream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                var zipfile = new ZipFile(filestream);
                ZipEntry item;

                while ((item = zip.GetNextEntry()) != null)
                {
                    Match match = Regex.Match(item.Name.ToLower(), @"Payload/([A-Za-z0-9\-. ]+)\/info.plist$",
                        RegexOptions.IgnoreCase);
                    if (match.Success)
                    {
                        var bytes = new byte[50*1024];

                        using (Stream strm = zipfile.GetInputStream(item))
                        {
                            int size = strm.Read(bytes, 0, bytes.Length);

                            using (var s = new BinaryReader(strm))
                            {
                                var bytes2 = new byte[size];
                                Array.Copy(bytes, bytes2, size);
                                plist = (Dictionary<string, object>) PlistCS.readPlist(bytes2);
                            }
                        }

                        break;
                    }
                }
            }
            return plist;
        }
开发者ID:hdxiong,项目名称:IPAParser,代码行数:35,代码来源:IOSBundle.cs

示例13: UnZipFile

 public static void UnZipFile(string[] args)
 {
     ZipInputStream zipInputStream = new ZipInputStream((Stream) File.OpenRead(args[0].Trim()));
       string directoryName = Path.GetDirectoryName(args[1].Trim());
       if (!Directory.Exists(args[1].Trim()))
     Directory.CreateDirectory(directoryName);
       ZipEntry nextEntry;
       while ((nextEntry = zipInputStream.GetNextEntry()) != null)
       {
     string fileName = Path.GetFileName(nextEntry.Name);
     if (fileName != string.Empty)
     {
       FileStream fileStream = File.Create(args[1].Trim() + fileName);
       byte[] buffer = new byte[2048];
       while (true)
       {
     int count = zipInputStream.Read(buffer, 0, buffer.Length);
     if (count > 0)
       fileStream.Write(buffer, 0, count);
     else
       break;
       }
       fileStream.Close();
     }
       }
       zipInputStream.Close();
 }
开发者ID:wangyuanxun,项目名称:DataOperator,代码行数:27,代码来源:UnZipTools.cs

示例14: Extract

        public void Extract(string path, string dest_dir)
        {
            ZipInputStream zipstream = new ZipInputStream(new FileStream( path, FileMode.Open));

              ZipEntry theEntry;
              while ((theEntry = zipstream.GetNextEntry()) != null) {
            string directoryName = Path.GetDirectoryName(theEntry.Name);
            string fileName      = Path.GetFileName(theEntry.Name);

            // create directory
            if (directoryName != String.Empty)
                Directory.CreateDirectory(directoryName);

            if (fileName != String.Empty) {
                FileStream streamWriter = File.Create( Path.Combine( dest_dir, theEntry.Name) );

                int size = 0;
                byte[] buffer = new byte[2048];
                while ((size = zipstream.Read(buffer, 0, buffer.Length)) > 0) {
                    streamWriter.Write(buffer, 0, size);
                }
                streamWriter.Close();
            }
              }
              zipstream.Close();
        }
开发者ID:GNOME,项目名称:capuchin,代码行数:26,代码来源:ZipExtracter.cs

示例15: RestoreFromFile

 private void RestoreFromFile(Stream file)
 {
         //
         //
         using (var store = IsolatedStorageFile.GetUserStoreForApplication()) {
                 using (var zip = new ZipInputStream(file)) {
                         try {
                                 while (true) {
                                         var ze = zip.GetNextEntry();
                                         if (ze == null) break;
                                         using (var f = new IsolatedStorageFileStream(ze.Name, FileMode.Create, store)) {
                                                 var fs = new byte[ze.Size];
                                                 zip.Read(fs, 0, fs.Length);
                                                 f.Write(fs, 0, fs.Length);
                                         }
                                 }
                         } catch {
                                 lblLastBackup.Text = StringResources.BackupAndRestorePage_Messages_RestoreFailed;
                                 App.ToastMe(StringResources.BackupAndRestorePage_Messages_RestoreFailed);
                                 return;
                         } finally {
                                 file.Close();
                                 ClearOldBackupFiles();
                                 App.ViewModel.IsRvDataChanged = true;
                         }
                 }
         }
         lblLastBackup.Text = StringResources.BackupAndRestorePage_Messages_RestoreSuccess;
         App.ToastMe(StringResources.BackupAndRestorePage_Messages_RestoreSuccess);
 }
开发者ID:tymiles003,项目名称:FieldService,代码行数:30,代码来源:BackupAndRestorePage.xaml.cs


注:本文中的ICSharpCode.SharpZipLib.Zip.ZipInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。