[Already Fixed] In SharpCompress 0.41 IWriter.Write might create empty file instead of directory #731

Closed
opened 2026-01-29 22:16:31 +00:00 by claunia · 2 comments
Owner

Originally created by @zhuxb711 on GitHub (Nov 28, 2025).

In 0.41, only IWriter.Write is available and IWriter.WriteDirectory is not exists.
To create an empty directory, usually, just like SharpZipLib, we will run the code below:

Writer.Write("test-empty-folder\", Stream.Null);

However, the \ will be removed through the NormalizeFilename inside ZipWriter & TarWriter, will make the zero byte file with same name as directory.

095c871174/src/SharpCompress/Writers/Tar/TarWriter.cs (L127)

However, this issue should be fixed in the latest code, which introduced the IWriter.WriteDirectory
Please publish the new release ASAP if possible, or maybe we should publish the night build every day to Nuget for early access, thanks~

Originally created by @zhuxb711 on GitHub (Nov 28, 2025). In 0.41, only `IWriter.Write` is available and `IWriter.WriteDirectory` is not exists. To create an empty directory, usually, just like [SharpZipLib](https://github.com/icsharpcode/SharpZipLib), we will run the code below: ```csharp Writer.Write("test-empty-folder\", Stream.Null); ``` However, the `\` will be removed through the `NormalizeFilename` inside `ZipWriter` & `TarWriter`, will make the zero byte file with same name as directory. https://github.com/adamhathcock/sharpcompress/blob/095c871174585c436541d8dcb3b189e89040c093/src/SharpCompress/Writers/Tar/TarWriter.cs#L127 However, this issue should be fixed in the latest code, which introduced the `IWriter.WriteDirectory` Please publish the new release ASAP if possible, or maybe we should publish the night build every day to Nuget for early access, thanks~
Author
Owner

@zhuxb711 commented on GitHub (Nov 29, 2025):

Fixed in 0.42

@zhuxb711 commented on GitHub (Nov 29, 2025): Fixed in 0.42
Author
Owner

@adamhathcock commented on GitHub (Nov 29, 2025):

🥳

@adamhathcock commented on GitHub (Nov 29, 2025): 🥳
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#731