C# .NET 使用第三方类库DotNetZip解压/压缩Zip文件 (ZT)

时间:2014-05-29 03:48:21   收藏:0   阅读:273

DotNetZip on CodePlex: http://dotnetzip.codeplex.com/

详细的可以看源代码……总之感觉比SharpZipLib好用。而且DotNetZip支持VB,C#以及任何.NET语言。

加压:(从CodePlex上偷过来的)

bubuko.com,布布扣
bubuko.com,布布扣
 using (ZipFile zip = new ZipFile())
 {
     // add this map file into the "images" directory in the zip archive 把这个PNG文件添加到zip档案的"images"目录下
     zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
     // add the report into a different directory in the archive 然后把PDF文件添加到zip档案的"files"目录下,把ReadMe.txt放到根目录
     zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
     zip.AddFile("ReadMe.txt");
   // 把zip档案保存为MyZipFile.zip
     zip.Save("MyZipFile.zip");
 }
bubuko.com,布布扣
bubuko.com,布布扣

解压更简单:

using (ZipFile zip = new ZipFile("MyZipFile.zip"))
{
  zip.ExtractAll("c:\\myfolder", ExtractExistingFileAction.OverwriteSilently);
}

这就可以了!什么问题都木有,是不是比SharpZipLib方便多了!

C# .NET 使用第三方类库DotNetZip解压/压缩Zip文件 (ZT),布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!