+1 vote
by (280 points)
edited

RebexZip does not add directory entries to the zip archive, is there a way I can force these to be added?

Rebexzip zip entries (2):

root.txt
a/file in directory a.txt

Winzip / Winrar zip entries (3):

root.txt
a/
a/file in directory a.txt

In this case "a/" is missing from rebex archive, causing a 3rd parties unzip function to fail. (they use java)

Code I am using to read the zip entries: http://www.roseindia.net/tutorial/java/corejava/zip/ShowEntries.html

This code also doesnt show directory: http://www.java-examples.com/determine-if-zip-entry-directory-example

==== Additional details to replicate

        using (ZipArchive zip = new ZipArchive(@"E:\\rebex3.zip"))
        {
            // This line is not calling 'CreateDirectory' internally for directories
            zip.Add(@"E:\z\*", @"\", Rebex.IO.TraversalMode.Recursive);

            // Manually adding directory & adding a file add the correct entries
            zip.CreateDirectory(@"\test");
            zip.AddFile(@"E:\temp\x.pdf", @"\test\x.pdf");
        }

produces the following entries output (note missing "a/")

root.txt
a/file in directory a.txt
test/
test/x.pdf

===========

Will you fix this or should I simply write my own method for adding directories to a zip archive recursively?

Applies to: Rebex ZIP
by (17.7k points)
edited

I need to consult it with developer who is on vacation now. We'll try to answer you later.

by (280 points)
edited

I have worked around the problem by creating the folders manually, so this could be moved to wish list.

thank you, have a great 2014.

2 Answers

0 votes
by (15.2k points)
edited

Rebex ZIP 2014 R1 adds ZipArchiveOptions.CreateDirectoryEntries option that causes directory entries to always be created.

To workaround the issue you reported, please enable the newly added option like this:

zip.Options.CreateDirectoryEntries = true;
by (280 points)
edited

Do you have a release schedule I can work towards or could you provide a pre-release version (I am a licensed user) thanks.

by (15.2k points)
edited

Hi Chris, please send us your pre-release request on support@rebex.net from your registered emial and we will make one for you.

by (132k points)
edited

Rebex ZIP 2014 R1 has just been released and includes this option.

0 votes
by (280 points)
edited

Sorry it's taken a while to get back to you, I have tried the hot fix you sent me with the following directory structure:

E:>tree /F E:\z Folder PATH listing Volume serial number is 0839-D1FE E:\Z │ file in root.txt │ └───a │ file in folder a.txt │ └───b file in folder b.txt E:>

When I create a zip using the hotfix I get the following entries:

List of contents in zip file file in root.txt a/file in folder a.txt a/b/file in folder b.txt

When I create a zip via windows or winrar I get the following

List of contents in zip file z/ z/a/ z/a/b/ z/a/b/file in folder b.txt z/a/file in folder a.txt z/file in root.txt

I am using the following code and the HotfixBuild5135:

        using (ZipArchive zip = new ZipArchive(@"E:\\rebex3.zip"))
        {
            zip.Add(@"E:\z\*", @"\", Rebex.IO.TraversalMode.Recursive);
        }

Do I need to make any code changes, I am 100% sure I am using the correct DLL as I made a blank project.

by (132k points)
edited

Please try enabling the new option by adding zip.Options.CreateDirectoryEntries = true; to your code. It is false by default.

by (280 points)
edited

Thanks, I can confirm it works now.

List of contents in zip file
file in root.txt
a/
a/file in folder a.txt
a/b/
a/b/file in folder b.txt
...