Why can't Windows 7 extract files from my password protected zip-file created using DotNetZip?

J. Steen picture J. Steen · Mar 24, 2015 · Viewed 9.2k times · Source

I'm creating a password protected zip-file using DotNetZip. When I try to extract the files I'm met with an "unspecified error". Why is that?

using (var zipFile = new ZipFile())
{
    zipFile.Encryption = EncryptionAlgorithm.WinZipAes256;
    zipFile.Password = "pangolin";

    foreach(var file in someFileCollection)
    {
        zipFile.AddEntry(file.Name, file.Stream);
    }

    zipFile.Save(aPathOnDisk);
}

Answer

J. Steen picture J. Steen · Mar 24, 2015

This is because Windows and more specifically Windows Explorer can't handle AES-level encryption and requires the encryption level to be set to PkzipWeak which is documented as "Traditional or Classic pkzip encryption."

zipFile.Encryption = EncryptionAlgorithm.PkzipWeak;

According to the documentation on the EncryptionAlgorithm enumeration:

[...] if you produce a zip archive using WinZipAes256, you will be able to open it in Windows Explorer on Windows XP and Vista, but you will not be able to extract entries; trying this will lead to an "unspecified error".

Note: popular third-party archive-utilities such as WinZip or 7-Zip can handle AES-encryption just fine. It's Windows Explorer that's the weak card in the deck.