Writing an empty directory into a zip file

Dec 17, 2007 at 11:17 PM
Hi

It doesn't look like the library supports writing an empty directory into the zip file.

The ZipDirEntry only has read methods. Am I missing something?
Dec 19, 2007 at 6:13 PM
I'm getting the same thing. I'm very interested in seeing a zip/unzip package that can handle empty folders as well. It seems like whatever is out there has this mental block against getting this one part right instead of forcing one to go out and implement it themselves. Kind of defeats the purpose of having a package that works for you instead of being just a starting point.
Dec 20, 2007 at 2:16 AM
I've had some limited success using the J# zip libraries. If you add a trailing "/" to the end of the empty folder name, the J# ZipEntry object recognizes it as a directory when adding it the the zip stream. Looking at the zip file with winzip or winrar will show it as an empty folder. However, when you look at the contents of the archive with the built in Windows compression tool, it recognizes the empty directory as a file without an extension (clearly labeling it as file). When I try to unpack the archive, Win2k3 has no problem with it (it unpacks as an empty directory), but Vista chokes on it with a security or permission violation.
Dec 20, 2007 at 3:01 AM
Kometes,

I'd be interested in seeing what your J# code looks like to see if I can use it by also writing my own J# code to undo the zip. I tried the same thing with this DotNet Zip library, i.e., writing my own ZipDir in which I traverse and parse the directory hierarchy, recognizing those folders that are empty and explicitly trying to create an empty folder by doing an AddItem or AddDirectory for the empty directory (with a trailing "\") but the library is not doing it. In fact, I'm printing out the output of the operations, and the AddItem or AddDirectory calls pretend to be adding the item by outputing the following:

adding .\ziptest\afile.txt...
adding .\ziptest\emptydir\... <----- this is the cursed empty directory we are all trying to create
adding .\ziptest\fulldir\...
adding .\ziptest\fulldir\doc1.doc...

But the zip file lacks ".\ziptest\emptydir". I have a hard believing this is such a terribly difficult problem that none of these packages can do it right. I challenge the authors of this package to fix this problem!
Coordinator
Jan 8, 2008 at 12:57 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jan 30, 2008 at 11:32 PM
This is now fixed in the source code, see changeset 14398.
Jul 3, 2008 at 8:06 AM
Edited Jul 3, 2008 at 9:38 AM
Hi I'm using the latest release (1.5), but I can't seem to get this working.

Basically I'm attempting to create a new archive in memory, create the (empty) folder structure, and then populate the folders with files.

I can't add the empty folders.  I'd like to simply do something along the lines of:

myZipFile.CreateDirectory("Folder1"); // create folder1 in the root
myZipFile.CreateDirectory("Folder2", "Folder1"); // create folder2 inside folder1

Are there any examples of how to achieve this?

Many thanks, S