Testing zip files for corruption

Apr 9, 2011 at 8:06 PM

 

I'm looking for a way for testing testing zip files for corruption, in c#. Just scanning and testing the files, no unpacking or anything else. Anyone who can give me a hint?

thanks,

Rich

Coordinator
Apr 11, 2011 at 1:56 PM

There's a static CheckZip method on the ZipFile class within this library.

There's an overload that actually unpacks/uncompresses the files - dumping all the data into a nbull stream - and therefore validates all the CRCs.  there's also an overload that skips that step.

It works only for zipfiles that don't have password protection on any of the entries. If you have passwords, then you need to do it "manually", that is to say, you can open, read and "scan" the zipfile with "new ZipFile(filename)" , and then you can optionally verify CRCs by calling Extract() on each entry, passing System.IO.Stream.Null as the destination stream.

Apr 11, 2011 at 3:06 PM

 

Sounds good, will look into it...

Thanks very much!

Rich