[PR #854] return Stream.Null when 7z entry has no stream #1289

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

Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/854

State: closed
Merged: Yes


bug: 7z file extraction fails when the archive contains empty file

I'm using the following code to extract a 7z file:

using var sevenZip = SharpCompress.Archives.SevenZip.SevenZipArchive.Open(data);
sevenZip.WriteToDirectory(root);

But it fails when the archive file (data) contains an empy file.
The same GetCompressedStream method returns Stream.Null, I think this method should also return Stream.Null instead throwing an exception.

It would be good to put an empy file to the tests\TestArchives\Original folder and to all the test files, to cover this case in the tests, but I don't know how to create them.

**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/854 **State:** closed **Merged:** Yes --- bug: 7z file extraction fails when the archive contains empty file I'm using the following code to extract a 7z file: ``` using var sevenZip = SharpCompress.Archives.SevenZip.SevenZipArchive.Open(data); sevenZip.WriteToDirectory(root); ``` But it fails when the archive file (`data`) contains an empy file. The same `GetCompressedStream` method returns `Stream.Null`, I think this method should also return `Stream.Null` instead throwing an exception. It would be good to put an empy file to the tests\TestArchives\Original folder and to all the test files, to cover this case in the tests, but I don't know how to create them.
claunia added the pull-request label 2026-01-29 22:19:49 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1289