Verify / Test a Zip Archive
Question:
I need an easy way to verify that a zip downloaded, i.e test it, preferably without actually unzipping it to a directory. I couldn’t find any method like that – the files are small enough in the zip I could probably unzip them into memory. Is that pretty much the only way to do it short of actually unzipping them?
Answer:
The Chilkat.Zip.OpenZip method can be used to verify a .zip. It walks the file headers and central directory and verifies that they are valid. It is not possible to verify the compressed data without actually decompressing every bit. For a good graphical picture of the zip file format (making it easy to understand) see the Wikipedia article on the Zip file format.
The OpenZip method returns false if there is an error (and also of course for other problems, such as “file not found”). It is possible to call OpenZip on an encrypted Zip without providing the password because the password is only required to decrypt the actual data. The file headers and central directory are still readable w/out a password.