2012-06-18 49 views
2

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

这个例子存储在“C:\ Program Files文件(x86)的\ IIS快车”的MyZipFile.zip,我不能在网络上找到任何简单的例子,有没有办法改变这条道路?我怀疑我有权访问我的虚拟主机。

+0

究竟什么是你问?只需提供文件的完整路径。 –

回答

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

+1

上帝,我感到愚蠢,漫长的一天!谢谢! – BjarkeCK

+0

@BjarkeCK:最受欢迎 –