Che*_*eso 22
使用DotNetZip,ZipFile类上有一个AddDirectory()方法,可以执行您想要的操作:
using (var zip = new Ionic.Zip.ZipFile())
{
zip.AddDirectory("DirectoryOnDisk", "rootInZipFile");
zip.Save("MyFile.zip");
}
Run Code Online (Sandbox Code Playgroud)
ZipFile.CreateFromDirectory(<path of folder you need to zip>, <path of zip file with .zip in the end>, CompressionLevel.Fastest, true);
Run Code Online (Sandbox Code Playgroud)