DotNetZip保存位置

Bja*_*eCK 2 c# zip dotnetzip

莫因!

 using (ZipFile zip = new ZipFile())
 {
     // add this map file into the "images" directory in the zip archive
     zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
     // add the report into a different directory in the archive
     zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
     zip.AddFile("ReadMe.txt");
     zip.Save("MyZipFile.zip");
 }
Run Code Online (Sandbox Code Playgroud)

这个例子将MyZipFile.zip存储在"C:\ Program Files(x86)\ IIS Express"中,我在网上找不到任何简单的例子有没有办法改变那条路径?我怀疑我有权访问我的虚拟主机.

Sar*_*edi 11

在保存方法或声明时更改路径.

ZipFile zip = new ZipFile("C:\\MyFile.Zip");
Run Code Online (Sandbox Code Playgroud)

要么

using (ZipFile zip = new ZipFile())
 {
     // add this map file into the "images" directory in the zip archive
     zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
     // add the report into a different directory in the archive
     zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
     zip.AddFile("ReadMe.txt");
     zip.Save("C:\\MyZipFile.zip");
 }
Run Code Online (Sandbox Code Playgroud)

获得更多帮助DotNetZip