前几天在网上搜了好多解压缩的方法,发现都不是很好,然后就找到了这个ICSharpCode.SharpZipLib
首先我们新建.net core 控制台应用程序,下载引用ICSharpCode.SharpZipLib
压缩方法:
1 FastZip fastZip = new FastZip(); 2 3 bool recurse = true; // Include all files by recursing through the directory structure 4 string filter = null; // Dont filter any files at all 5 fastZip.CreateZip("fileName.zip", @"C:SourceDirectory", recurse, filter);
解压方法:
1 public void TestFastZipUnpack(string zipFileName, string targetDir) { 2 3 FastZip fastZip = new FastZip(); 4 string fileFilter = null; 5 6 // Will always overwrite if target filenames already exist 7 fastZip.ExtractZip(zipFileName, targetDir, fileFilter); 8 }
具体资料请查看https://github.com/icsharpcode/SharpZipLib/wiki/FastZip