This project is read-only.

How to extract single file from zip sub directory?

Mar 20, 2009 at 6:47 PM
This is probably way easier than I am making it, but it is not working.  I have a zip, say named "" and in the zip is a directory called "install" and in the directory is a file called "MyFile.ini" and I simply want to extract that file.  I have no problem getting the file if it is not in a sub directory using something like this:

using (ZipFile zip = ZipFile.Read("C:\\"))
                zip.Extract("MyFile.ini", "C:\\", true);


But, if I try to get it out of the sub directory it fails:

using (ZipFile zip = ZipFile.Read("C:\\"))
                zip.Extract("\\install\\MyFile.ini", "C:\\", true);


I am sure it it user error but can someone enlighten me?

Mar 22, 2009 at 1:04 AM
Edited Mar 22, 2009 at 2:08 AM
I figured it out, I guess, but I am not sure if what I am seeing is the desired results.  It seems that when I extract a file from a sub directory of a zip file that the DotNetZip library automatically creates a directory with the same name in the specified extraction location, therefore, given my example above, "MyFile.ini" is not actually extracted to "C:\" rather it is extracted to "C:\install"  While I can certainly live with this, I am not sure this should be the default behavior and I cannot find any information in the help file one it either.
Mar 22, 2009 at 6:03 AM
Ah, yes - what you observed is the expected behavior.
I will make the documentation clearer on that.