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