dotNetZip on CodePlex: http://dotnetzip.codeplex.com/
压缩:
//1.压缩 //指定编码,防止中文乱码情况 using (ZipFile zip = new ZipFile(System.Text.Encoding.UTF8)) { // add this map file into the "images" directory in the zip archive 将该地图文件添加到zip存档中的“images”目录中 zip.AddFile(@"E:\DemoZip\1.png", "images"); // add the report into a different directory in the archive 将报告添加到归档中的其他目录中 zip.AddFile(@"E:\DemoZip\2.txt", "files"); // 添加到根目录 zip.AddFile(@"E:\DemoZip\3.txt"); zip.Save(@"E:\DemoZip\ZipFile.zip"); } //2.解压 //指定编码,防止存在中文乱码情况 //如情况:路径中具有非法字符 using (ZipFile zip = new ZipFile(@"E:\DemoZip\ZipFile.zip", System.Text.Encoding.UTF8)) { zip.ExtractAll(@"E:\DemoZip\ZipFileFolder", ExtractExistingFileAction.OverwriteSilently); }
时间: 2024-10-07 19:12:55