You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception when reading an encrypted zip file containing a folder: "Stored, but compressed != uncompressed" #885
When I use a ZipInputStream to read a zip file that is encrypted and contains folder entries, the following exception occurs:
ICSharpCode.SharpZipLib.Zip.ZipException: 'Stored, but compressed != uncompressed'
Here is the zip file that is causing the exception. It was created using SharpZipLib and can be opened fine using other zip applications or libraries: archive.zip
In the code below, it fails when calling GetNextEntry():
using var archive = new ZipInputStream(File.OpenRead(archiveFilePath))
{
Password = "123456"
};
ZipEntry entry;
while ((entry = archive.GetNextEntry()) != null)
{
Console.WriteLine(entry.Name);
}
I have created a PR to fix this error. I believe the source of this error is due to ZipFile changing the compression method from Deflate to Stored for directories even if they are encrypted. When reading using ZipInputStream, it checks for an encryption header if it is encrypted and if it is Stored.
When creating a directory with ZipOutputStream, the directory is NOT set to Stored despite being empty
Activity
bwinsley commentedon Nov 14, 2025
I have created a PR to fix this error. I believe the source of this error is due to ZipFile changing the compression method from Deflate to Stored for directories even if they are encrypted. When reading using ZipInputStream, it checks for an encryption header if it is encrypted and if it is Stored.
When creating a directory with ZipOutputStream, the directory is NOT set to Stored despite being empty