Search code examples
c#zipdotnetzip

DotNetZip Save location


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.


Solution

  • 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