C# .NET 使用第三方类库DotNetZip解压/压缩Zip文件
2024-10-18 23:46:03
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.zip
zip.Save("MyZipFile.zip");
}
解压更简单:
using (ZipFile zip = new ZipFile("MyZipFile.zip"))
{
zip.ExtractAll("c:\\myfolder", ExtractExistingFileAction.OverwriteSilently);
}
这就可以了!什么问题都木有,是不是比SharpZipLib方便多了!
最新文章
- Inverted sentences
- Des加解密算法
- HTML 学习笔记 CSS样式(背景)
- Java Code Examples for javax.servlet.http.Part
- Fbric、Ansible、Docker、Chaos Monkey:DevOps工具的年中回顾
- JAVA大数运算
- 沈逸老师PHP魔鬼特训笔记(6)--巫术与骨架
- EF 实体字段设置主键和自增
- Fibonacci Numbers
- /etc/security/limits.conf不生效
- Linux seq_printf输出内容不完整的问题
- mysql查看连接数排查问题
- Linux搭建SVN环境
- 相对于父元素的fixed定位的实现
- 让对象支持with语句
- java中二维数组的复制克隆
- URL helper 逆向破解思路+详细过程 利用messagebox破解
- Java套接字Socket编程--TCP参数
- 2018/03/20 每日一个Linux命令 之 cp
- unity5 where is ";Edit->;Render Settings";?