Unzip strange beaviour

Feb 26, 2010 at 9:39 AM


I try to unzip files that have been stored with relative path but it seems that the base directory parameters used in the ZipEntry.Extract(BaseDirectory) is not working as i supposed it should

I have a Zip Test1.zip that Have two files inside it



And I want to extract these files to the D:\testing-directory

So I wrote the following code

using (ZipFile zip = ZipFile.Read(@"D:\test.zip"))
	foreach (ZipEntry item in zip)

but my files are always written in the d:\test folder

I also try the zip.ExtractAll((@"D:\testing-directory"); with the same issue

Do you know why ?



Feb 26, 2010 at 10:17 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 26, 2010 at 10:18 AM

yes.  if your zip file entries contain a leading slash, then they are being placed into the root directory.  The convention in zip files is to have no leading slash.

It seems there are at least two problems:

  1. the program or tool you used to create the zip files has inserted a leading slash. 
  2. DotNetZip does not correctly handle the leading slash well when extracting

I can fix the latter. Please upload your zip file to the workitem. 

If you used DotNetZip to produce the zip file, then I will have to also fix the first problem, too. In that case, please post the code you used to produce the zip file.

Feb 26, 2010 at 12:19 PM

Ok I will swithed to the new work item