欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > C# >内容正文

C#

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

发布时间:2025/7/25 C# 98 豆豆
生活随笔 收集整理的这篇文章主要介绍了 C# .NET 使用第三方类库DotNetZip解压/压缩Zip文件 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
dotNetZip on CodePlex: http://dotnetzip.codeplex.com/

详细的可以看源代码……总之感觉比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.zipzip.Save("MyZipFile.zip");}

解压更简单:

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

 

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

 

转载于:https://www.cnblogs.com/damsoft/p/6100320.html

总结

以上是生活随笔为你收集整理的C# .NET 使用第三方类库DotNetZip解压/压缩Zip文件的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。