haf / DotNetZip.Semverd

Please use System.IO.Compression! A fork of the DotNetZip project without signing with a solution that compiles cleanly. This project aims to follow semver to avoid versioning conflicts. DotNetZip is a FAST, FREE class library and toolset for manipulating zip files. Use VB, C# or any .NET language to easily create, extract, or update zip files.
Other
545 stars 218 forks source link

Windows cannot open the folder #281

Closed sierks closed 1 year ago

sierks commented 1 year ago

I am using the latest DotNetZip nuget package to create Zip files. However, for many of them (but not all), I get an error message when opening the Zip files in Windows. “Windows cannot open the folder.”

The Zip files can be opened via code. They can also be opened via 7zip. But not Windows.

I've tested with dozens of different files and file types and haven't found any specifics. But in these test PDFs, the "Public" one appears to be causing my issues. And I've validated it and it appears to be a good PDF. But it also happens with other files and file types.

When compared to a Zip file of the same source files created via Windows, the DotNetZip file is significantly larger. The source files are PDFs and I’ve validated them and they appear to be valid.

The Zip file passes the verification check. And DotNetZip can open it.

This is my code for creating the Zip. It's very basic. It's all in memory as I have a web app. But this code comes from my Unit Test project and it's basically the same.

` using (var ms = new System.IO.MemoryStream()) { using (var archive = new Ionic.Zip.ZipFile()) { foreach (var item in all) { archive.AddEntry(item.Name, item.Data); }

                archive.Save(ms);
            }
        }

`

Works - DotNetZip_PublicNotDeleted.zip Fails - DotNetZip.zip Fails - DotNetZip_PublicDeletedAndReAdded.zip Works - DotNetZip_DoubledNoPublic.zip Works - DotNetZip_NoPublic.zip Works - DotNetZip_Public.zip Works - DotNetZip_PublicDeleted.zip Works - DotNetZip_PublicDoubled.zip

sierks commented 1 year ago

Don't use GetBuffer on a MemoryStream. Use ToArray instead.