DotNetZip Save location

BjarkeCK picture BjarkeCK · Jun 18, 2012 · Viewed 12.5k times · Source

Moin!

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

This example stores the MyZipFile.zip in "C:\Program Files (x86)\IIS Express", i can't find any simple examples on the net Is there any way to change that path? i doubt i have permissions to go there on my webhost.

Answer

Saroop Trivedi picture Saroop Trivedi · Jun 18, 2012

Change the path in your save method or at time of declaration.

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

or

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

for more help DotNetZip