Cannot open encrypted zip file - NotSupportedException #468

Open
opened 2026-01-29 22:12:33 +00:00 by claunia · 8 comments
Owner

Originally created by @henning-krause on GitHub (Jul 28, 2021).

Hi,

I think I ran accross a similiar problem as @ArunaVignesh in #504.

When I open my Zip file using

var x = ReaderFactory.Open(File.OpenRead(filename));

I get this NotSupportedException:

cfef228afc/src/SharpCompress/Common/Zip/ZipHeaderFactory.cs (L117-L121)

For my file, these are the entryHeader properties:
entryHeader.IsDirectory: false
entryHeader.CompressedSize: 0
entryHeader.Flags: Encrypted, Bit1, UsePostDataDescriptor, Efs

I'm happy to work on this issue and and provide a PR, but I'm not really sure if the changes that @ArunaVignesh suggested are viable.

Any help on why that check is there would be appreciated.

Originally created by @henning-krause on GitHub (Jul 28, 2021). Hi, I think I ran accross a similiar problem as @ArunaVignesh in #504. When I open my Zip file using ```cs var x = ReaderFactory.Open(File.OpenRead(filename)); ``` I get this NotSupportedException: https://github.com/adamhathcock/sharpcompress/blob/cfef228afc7ca390f449efbca9de9d7d8db81182/src/SharpCompress/Common/Zip/ZipHeaderFactory.cs#L117-L121 For my file, these are the entryHeader properties: entryHeader.IsDirectory: false entryHeader.CompressedSize: 0 entryHeader.Flags: Encrypted, Bit1, UsePostDataDescriptor, Efs I'm happy to work on this issue and and provide a PR, but I'm not really sure if the changes that @ArunaVignesh suggested are viable. Any help on why that check is there would be appreciated.
claunia added the question label 2026-01-29 22:12:33 +00:00
Author
Owner

@adamhathcock commented on GitHub (Aug 17, 2021):

Not all zip files can be read in a non-seekable way. The knowledge of things like size would need to be in the post data descriptor header if you're using ReaderFactory If this header doesn't exist then it needs the zip dictionary which must be seeked upon to read. This is done using ArchiveFactory

@adamhathcock commented on GitHub (Aug 17, 2021): Not all zip files can be read in a non-seekable way. The knowledge of things like size would need to be in the post data descriptor header if you're using `ReaderFactory` If this header doesn't exist then it needs the zip dictionary which must be seeked upon to read. This is done using `ArchiveFactory`
Author
Owner

@bhaeussermann commented on GitHub (May 5, 2025):

@adamhathcock I'm facing the same problem with my zip file as the one reported in this issue, so I tried using ArchiveFactory as suggested as follows:

var readerOptions = new ReaderOptions { Password = "[my password]" };
using var factory = ArchiveFactory.Open(filePath, readerOptions);

However, it's failing to identify the file as a valid zip as it's failing with the following exception:

System.InvalidOperationException: 'Cannot determine compressed stream type. Supported Archive Formats: Zip, Rar, 7Zip, GZip, Tar'

Any suggestions on how to deal with this type of zip file?

@bhaeussermann commented on GitHub (May 5, 2025): @adamhathcock I'm facing the same problem with my zip file as the one reported in this issue, so I tried using `ArchiveFactory` as suggested as follows: ``` var readerOptions = new ReaderOptions { Password = "[my password]" }; using var factory = ArchiveFactory.Open(filePath, readerOptions); ``` However, it's failing to identify the file as a valid zip as it's failing with the following exception: ``` System.InvalidOperationException: 'Cannot determine compressed stream type. Supported Archive Formats: Zip, Rar, 7Zip, GZip, Tar' ``` Any suggestions on how to deal with this type of zip file?
Author
Owner

@adamhathcock commented on GitHub (May 6, 2025):

Is it actually a valid zip file? What was it produced with? I'd need a sample before taking a look as it way it's failing.

@adamhathcock commented on GitHub (May 6, 2025): Is it actually a valid zip file? What was it produced with? I'd need a sample before taking a look as it way it's failing.
Author
Owner

@bhaeussermann commented on GitHub (May 8, 2025):

@adamhathcock The zip file must be valid as it can be unzipped using a zip application (eg. 7-zip).
Unfortunately, I cannot share the file as it contains sensitive information. I also don't know how it was produced.

@bhaeussermann commented on GitHub (May 8, 2025): @adamhathcock The zip file must be valid as it can be unzipped using a zip application (eg. 7-zip). Unfortunately, I cannot share the file as it contains sensitive information. I also don't know how it was produced.
Author
Owner

@BartRennes commented on GitHub (Jun 18, 2025):

I have the same problem, i tried with all methods but it fails each time, the error message:
cannot currently read non-seekable Zip Streams with encrypted data that has been written in a non-seekable manner.

It is password protected, i can send you the file to test but only in private.

@BartRennes commented on GitHub (Jun 18, 2025): I have the same problem, i tried with all methods but it fails each time, the error message: cannot currently read non-seekable Zip Streams with encrypted data that has been written in a non-seekable manner. It is password protected, i can send you the file to test but only in private.
Author
Owner

@jbrockerville commented on GitHub (Jul 4, 2025):

Following. I too am facing this issue and, unfortunately, also cannot share the files. @BartRennes did you end up sending your sample? Any progress?

@jbrockerville commented on GitHub (Jul 4, 2025): Following. I too am facing this issue and, unfortunately, also cannot share the files. @BartRennes did you end up sending your sample? Any progress?
Author
Owner

@adamhathcock commented on GitHub (Jul 7, 2025):

It's probably not a bad zip file if gets to that error. Just a missing feature which hasn't been implemented

@adamhathcock commented on GitHub (Jul 7, 2025): It's probably not a bad zip file if gets to that error. Just a missing feature which hasn't been implemented
Author
Owner

@BartRennes commented on GitHub (Jul 7, 2025):

Following. I too am facing this issue and, unfortunately, also cannot share the files. @BartRennes did you end up sending your sample? Any progress?

I didn't received answer to send the file sample, no progress, i added a new lib (SharpZipLib) to avoid this problem with SharpCompress.

@BartRennes commented on GitHub (Jul 7, 2025): > Following. I too am facing this issue and, unfortunately, also cannot share the files. [@BartRennes](https://github.com/BartRennes) did you end up sending your sample? Any progress? I didn't received answer to send the file sample, no progress, i added a new lib (SharpZipLib) to avoid this problem with SharpCompress.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#468