This project is read-only.

How to change the destination path?

Aug 20, 2010 at 1:06 PM
Edited Aug 20, 2010 at 1:14 PM


I am new using the DoNetZip Library. I am have a simple code to zip a folder:

 using (ZipFile zip = new ZipFile())



zip.AddDirectory(@"C:\Example\Example2"); //I want to zip the folder Example 2

 zip.Save(""); //New zip information



 catch (Exception e)





 I always get "" under the my projects files(bin) of  Visual Studio.

There is a way to change the destination path and that It creates under the same  directory; in this example under "C:\Examples\" ?


Thank you!

Aug 20, 2010 at 1:33 PM


I found the solution... :)

it´s just:"C:\Example\"+"")



Aug 20, 2010 at 1:53 PM

Ya, what you have will work, but:

  1. There's no need to do string concatenation, like so: "c:\Example\" + "" .  You can just specify the full path in one string: "c:\Example\". 
  2. If you DO use string concatenation to build paths, I suggest the base library function Path.Concat()
  3. Saving a zip file into the same folder that you are zipping, results in undefined behavior. 


Aug 20, 2010 at 2:24 PM

Hi Cheeso!


Thank you for your advice! However I didn´t understood the 3rd point. Why it results in undefined behavior?

Aug 21, 2010 at 4:22 AM
Edited Aug 26, 2010 at 12:10 AM

You're saving a zip to the directory that you are zipping. I suppose " undefined" is the wrong word. What I mean is non- idempotent. On the first attempt it will work. On succesive saves, when the zip already exists, the resulting zip may contain file entries that are not valid.

Aug 25, 2010 at 9:18 AM

ok!  now I understand what you mean :)

Greetings! and Thank u :)

Oct 27, 2010 at 10:03 AM

hi, i got a question about the zip file destination.

i zip a file named "123.txt", then i set the destination as "C:\Program File\"..but when i extract the folder in Program File, it wil extract the folder with full path i set previously, which mean the extracted file name is "Program File", the full path of my file 123.txt is "C:\Program File\Program File\123.txt"..if i set the destination name longer, then, it will extract my file in multiple layer, for example, destination is "C:\Program File\abc\efg\", after i extract it in my Program File, the 123.txt will have a path like this "C:\Program File\Program File\abc\efg\123.txt"..what i want is only the file extract to Program File but not multi layers folder.

can anyone help me? thank you very much....



Nov 1, 2010 at 3:30 AM

Important: open a new thread if you have a new question.