我试过了zip.AddDirectory
,但我不知道如何将整个文件夹导入存档(使用DotNetZip
)。
我不想要这个:
但是这个:
重新映射目录。压缩一组文件和目录,并将它们重新映射到 zip 文件中的不同目录层次结构中:
using (ZipFile zip = new ZipFile())
{
// files in the filesystem like MyDocuments\ProjectX\File1.txt , will be stored in the zip archive as backup\File1.txt
zip.AddDirectory(@"MyDocuments\ProjectX", "backup");
// files in the filesystem like MyMusic\Santana\OyeComoVa.mp3, will be stored in the zip archive as tunes\Santana\OyeComoVa.mp3
zip.AddDirectory("MyMusic", "tunes");
// The Readme.txt file in the filesystem will be stored in the zip archive as documents\Readme.txt
zip.AddDirectory("Readme.txt", "documents");
zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G") ;
zip.Save(ZipFileToCreate);
}