Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DotNetZip add files without creating folders

using (ZipFile zip = new ZipFile()) {     foreach(string file in Directory.GetFiles(folder))     {         zip.AddFile(file, Path.GetFileName(file));     }     zip.Save("test.zip")); } 

Each time I add a file, it's creating a new subfolder for it.

So I want to end up with:

test.zip     -  myDoc.doc     -  myPdf.pdf 

but I'm ending up with:

test.zip     -  myDoc.doc         -  myDoc.doc     -  myPdf.pdf         -  myPdf.pdf 
like image 654
fearofawhackplanet Avatar asked Nov 08 '10 16:11

fearofawhackplanet


1 Answers

How about just:

zip.AddFile(file,""); 

or

zip.AddFile(file,@"\"); 
like image 54
Fosco Avatar answered Oct 07 '22 16:10

Fosco