分享

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

 昵称10504424 2014-05-27

DotNetZip on CodePlex: http://dotnetzip./

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

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

复制代码
复制代码
 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");
 }
复制代码
复制代码

解压更简单:

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

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

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多