DotNetZip是您的朋友在这里。
一样容易:
using (ZipFile zip = ZipFile.Read(ExistingZipFile)){ ZipEntry e = zip["MyReport.doc"]; e.Extract(OutputStream);}(您也可以提取到文件或其他目标位置)。
读取zip文件的目录很容易:
using (ZipFile zip = ZipFile.Read(ExistingZipFile)){ foreach (ZipEntry e in zip) { if (header) { System.Console.WriteLine("Zipfile: {0}", zip.Name); if ((zip.Comment != null) && (zip.Comment != "")) System.Console.WriteLine("Comment: {0}", zip.Comment); System.Console.WriteLine("n{1,-22} {2,8} {3,5} {4,8} {5,3} {0}", "Filename", "Modified", "Size", "Ratio", "Packed", "pw?"); System.Console.WriteLine(new System.String('-', 72)); header = false; } System.Console.WriteLine("{1,-22} {2,8} {3,5:F0}% {4,8} {5,3} {0}", e.FileName, e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"), e.UncompressedSize, e.CompressionRatio, e.CompressedSize, (e.UsesEncryption) ? "Y" : "N"); }}编辑要注意:
DotNetZip曾经居住在Codeplex。Codeplex已关闭。旧的存档仍可在Codeplex上获得。看起来代码已迁移到Github:
- https://github.com/DinoChiesa/DotNetZip。看起来是原始作者的回购。
- https://github.com/haf/DotNetZip.Semverd。这似乎是当前维护的版本。它还通过Nuget打包在https://www.nuget.org/packages/DotNetZip/



