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

来源:互联网 发布:头戴式耳机 知乎 编辑:程序博客网 时间:2024/05/29 14:03

下载地址 http://dotnetzip.codeplex.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");            }            //解压            using (ZipFile zip = new ZipFile("MyZipFile.zip"))            {                zip.ExtractAll("c:\\myfolder", ExtractExistingFileAction.OverwriteSilently);            }


0 0
原创粉丝点击