3

我试过了zip.AddDirectory,但我不知道如何将整个文件夹导入存档(使用DotNetZip)。

想要这个:

在此处输入图像描述

但是这个:

在此处输入图像描述

4

1 回答 1

5

来自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);
}
于 2013-01-23T18:22:56.547 回答