2

嗬嗬!

 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");
 }

此示例将 MyZipFile.zip 存储在“C:\Program Files (x86)\IIS Express”中,我在网上找不到任何简单的示例有没有办法更改该路径?我怀疑我有权在我的虚拟主机上去那里。

4

1 回答 1

11

在您的保存方法中或在声明时更改路径。

ZipFile zip = new ZipFile("C:\\MyFile.Zip");

或者

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");
 }

更多帮助DotNetZip

于 2012-06-18T14:24:05.287 回答