2011-06-20 78 views

回答

36

從DotNetZip FAQ:

Add an entry, overriding its name in the archive

using (ZipFile zip1 = new ZipFile()) 
    { 
     zip1.AddFile("myFile.txt").FileName = "otherFile.txt"; 
     zip1.Save(archiveName); 
    } 
+0

謝謝...應該已經閱讀了FAQ – SFun28

+0

呵呵,我們都會不時地這樣做。 – Martin

+1

真棒,你拯救我的一天。謝謝 –

2
 var zip = new ZipFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.zip")); 
     var e = zip.AddFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "testfile.pdf"), "/"); 
     e.FileName = "PewPewGotcha.pdf"; 
     zip.Save(); 

一旦zip文件保存,名稱更新。

相關問題