Get NullReferenceException after saving last entry of a 7zip archive #16

Closed
opened 2026-01-29 22:03:32 +00:00 by claunia · 3 comments
Owner

Originally created by @donRumatta on GitHub (Apr 29, 2014).

I'm using the example:

var archive = ArchiveFactory.Open(item.FullName);
foreach (var entry in archive.Entries)
{
if (!entry.IsDirectory)
{
entry.WriteToDirectory(@"C:\Research\SharpCompress\SharpCompress\Archives");
}
}

Decompressing is done successfully only if file has some content. If it is empty I get NullReferenceException in ListeningStream.Read (Stream is null). As I understand archiveEntry.OpenEntryStream() returns null.

Archive can be downloaded from the same issue posted on CodePlex.

And it is important, that such issue appears only with 7zip, rar and zip are processed without errors.

UPD. the main reason is that file.HasStream = !emptyStreamVector[i]; is false for my archive. How can it be changed to true?

Originally created by @donRumatta on GitHub (Apr 29, 2014). I'm using the example: var archive = ArchiveFactory.Open(item.FullName); foreach (var entry in archive.Entries) { if (!entry.IsDirectory) { entry.WriteToDirectory(@"C:\Research\SharpCompress\SharpCompress\Archives"); } } Decompressing is done successfully only if file has some content. If it is empty I get NullReferenceException in ListeningStream.Read (Stream is null). As I understand archiveEntry.OpenEntryStream() returns null. Archive can be downloaded from the same issue posted on CodePlex. And it is important, that such issue appears only with 7zip, rar and zip are processed without errors. UPD. the main reason is that file.HasStream = !emptyStreamVector[i]; is false for my archive. How can it be changed to true?
Author
Owner

@donRumatta commented on GitHub (Apr 29, 2014):

Temporally, I've added such a check to skip entry:

entry is SevenZipArchiveEntry && entry.Size == 0

But it would be great if decompressing of empty files is performed silently like in rar and zip cases.

@donRumatta commented on GitHub (Apr 29, 2014): Temporally, I've added such a check to skip entry: entry is SevenZipArchiveEntry && entry.Size == 0 But it would be great if decompressing of empty files is performed silently like in rar and zip cases.
Author
Owner

@adamhathcock commented on GitHub (Apr 30, 2014):

I added a null check for streams from OpenEntryStream: d1a64021e1

@adamhathcock commented on GitHub (Apr 30, 2014): I added a null check for streams from OpenEntryStream: https://github.com/adamhathcock/sharpcompress/commit/d1a64021e188e04769517ee7276a3e0690235b2d
Author
Owner

@donRumatta commented on GitHub (Apr 30, 2014):

Thank you.

@donRumatta commented on GitHub (Apr 30, 2014): Thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#16