Can't write empty directories to ZIP files #22

Open
opened 2026-01-29 22:03:36 +00:00 by claunia · 0 comments
Owner

Originally created by @ptallett on GitHub (Dec 26, 2014).

Attempting to create an empty directory entry in a ZIP file creates an empty file instead of a directory

A crude fix is as follows - in ZipWriter make the following change:

    public Stream WriteToStream(string entryPath, DateTime? modificationTime, string comment)
    {
        bool isDirectory = entryPath.EndsWith("/");             // PRT
        entryPath = NormalizeFilename(entryPath);
        if (isDirectory)                                        // PRT
            entryPath += "/";                                   // PRT

Cheers,
Paul

Originally created by @ptallett on GitHub (Dec 26, 2014). Attempting to create an empty directory entry in a ZIP file creates an empty file instead of a directory A crude fix is as follows - in ZipWriter make the following change: ``` public Stream WriteToStream(string entryPath, DateTime? modificationTime, string comment) { bool isDirectory = entryPath.EndsWith("/"); // PRT entryPath = NormalizeFilename(entryPath); if (isDirectory) // PRT entryPath += "/"; // PRT ``` Cheers, Paul
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#22