2011-06-20 20 views

Respuesta

36

Desde el FAQ DotNetZip:

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

gracias ... debería haber leído las preguntas más frecuentes – SFun28

+0

Jeje, todos lo hacemos de vez en cuando. – Martin

+1

increíble que me salves el día. Gracias –

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(); 

Una vez que el ZipFile se guarda, el nombre se actualiza.

Cuestiones relacionadas