• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Zip.ZipInputStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: UnZip

    /// <summary>
    /// 解压缩文件(压缩文件中含有子目录)
    /// </summary>
    /// <param name="zipfilepath">待解压缩的文件路径</param>
    /// <param name="unzippath">解压缩到指定目录</param>
    /// <returns>解压后的文件列表</returns>
    public List<string> UnZip(string zipfilepath, string unzippath)
    {
        //解压出来的文件列表
        List<string> unzipFiles = new List<string>();

        //检查输出目录是否以“\\”结尾
        if (unzippath.EndsWith("\\") == false || unzippath.EndsWith(":\\") == false)
        {
            unzippath += "\\";
        }

        ZipInputStream s = new ZipInputStream(File.OpenRead(zipfilepath));
        ZipEntry theEntry;
        while ((theEntry = s.GetNextEntry()) != null)
        {
            string directoryName = Path.GetDirectoryName(unzippath);
            string fileName = Path.GetFileName(theEntry.Name);

            //生成解压目录【用户解压到硬盘根目录时,不需要创建】
            if (!string.IsNullOrEmpty(directoryName))
            {
                Directory.CreateDirectory(directoryName);
            }

            if (fileName != String.Empty)
            {
                //如果文件的压缩后大小为0那么说明这个文件是空的,因此不需要进行读出写入
                if (theEntry.CompressedSize == 0)
                    break;
                //解压文件到指定的目录
                directoryName = Path.GetDirectoryName(unzippath + theEntry.Name);
                //建立下面的目录和子目录
                Directory.CreateDirectory(directoryName);

                //记录导出的文件
                unzipFiles.Add(unzippath + theEntry.Name);

                FileStream streamWriter = File.Create(unzippath + 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();
        GC.Collect();
        return unzipFiles;
    }
开发者ID:jongking,项目名称:XueXiaoWeiXin,代码行数:66,代码来源:ZipClass.cs


示例17: UnzipFile

        public static void UnzipFile(string directory, string zipFile, int patchNum)
        {
            using (ZipInputStream s = new ZipInputStream(File.OpenRead(directory + zipFile)))
            {
                ZipEntry theEntry;
                while ((theEntry = s.GetNextEntry()) != null)
                {
                    string directoryName = Path.GetDirectoryName(theEntry.Name);

                    // create directory
                    if (directoryName.Length > 0)
                    {
                        Directory.CreateDirectory(directory + directoryName);
                    }
                    string fileName = directory + "-" + patchNum + theEntry.Name;
                    if (fileName.Contains("patch" + patchNum + "info"))
                    {
                        fileName = directory + theEntry.Name;
                    }
                    Console.WriteLine("Unzipping file: {0}", fileName);
                    using (FileStream streamWriter = File.Create(fileName))
                    {
                        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;
                        }
                    }
                    Console.WriteLine("Unzipped: {0}", theEntry.Name);
                }
            }
        }
开发者ID:rsshah,项目名称:WzPatcher,代码行数:35,代码来源:Unzip.cs


示例18: File

        /// <summary>
        /// 解压缩文件
        /// </summary>
        /// <param name="zipPath">源文件</param>
        /// <param name="directory">目标文件</param>
        /// <param name="password">密码</param>
        public void File(string zipPath, string directory, string password = null) {
            FileInfo objFile = new FileInfo(zipPath);
            if (!objFile.Exists || !objFile.Extension.ToUpper().Equals(".ZIP")) return;
            FileDirectory.DirectoryCreate(directory);

            ZipInputStream objZIS = new ZipInputStream(System.IO.File.OpenRead(zipPath));
            if (!password.IsNullEmpty()) objZIS.Password = password;
            ZipEntry objEntry;
            while ((objEntry = objZIS.GetNextEntry()) != null) {
                string directoryName = Path.GetDirectoryName(objEntry.Name);
                string fileName = Path.GetFileName(objEntry.Name);
                if (directoryName != String.Empty) FileDirectory.DirectoryCreate(directory + directoryName);
                if (fileName != String.Empty) {
                    FileStream streamWriter = System.IO.File.Create(Path.Combine(directory, objEntry.Name));
                    int size = 2048;
                    byte[] data = new byte[2048];
                    while (true) {
                        size = objZIS.Read(data, 0, data.Length);
                        if (size > 0) {
                            streamWriter.Write(data, 0, size);
                        } else {
                            break;
                        }
                    }
                    streamWriter.Close();
                }
            }
            objZIS.Close();
        }
开发者ID:pczy,项目名称:Pub.Class,代码行数:35,代码来源:Decompress.cs


示例19: UnZip

 protected Stream UnZip(Stream input)
 {
     var zipInputStream = new ZipInputStream(input);
     if (zipInputStream.GetNextEntry() == null)
         throw new ZipException("Can't unzip archive.");
     return zipInputStream;
 }
开发者ID:bdvsoft,项目名称:reader_wp8_OPDS,代码行数:7,代码来源:BaseFileLoader.cs


示例20: Unzip

        public static void Unzip(string file)
        {
            using (ZipInputStream s = new ZipInputStream(File.OpenRead(file))) {

            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
                if ( directoryName.Length > 0 ) {
                    Directory.CreateDirectory(directoryName);
                }

                if (fileName != String.Empty) {
                    using (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;
                            }
                        }
                    }
                }
            }
            }
        }
开发者ID:MegaBedder,项目名称:PHPRAT,代码行数:35,代码来源:Zip.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Zip.ZipNameTransform类代码示例发布时间:2022-05-26
下一篇:
C# Zip.ZipHelperStream类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap