1

I've tried to use CheckZip in DotNetZip to test about 22.000 zip files, and it doesn't report any errors. WinRAR however reports "archive is corrupted" for a number of these files, so I wonder what's going on here, and if I've implemented CheckZip correctly. If I rename a text file to test.zip and check it I get a "test.zip is not a valid zip file" from DotNetZip so it looks like it's basically working though. Code looks like this:

 public static bool CheckZip(string zipFileName)
        {
            try
            {
                return ZipFile.CheckZip(zipFileName);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return false;
            }
        }

UPDATE: found a simple solution here, using SharpZipLib instead. Works fine.

Rado
  • 151
  • 2
  • 13
  • 2
    What do you mean _"if I've implemented `CheckZip` correctly"_? All you do is call `ZipFile.CheckZip()`. Have you read its documentation to see what arguments it expects / what its limitations are? – Pranav Hosangadi May 04 '21 at 19:22
  • I haven't been able to find any documentation other than it's supposed to return "false" if a zip is bad (which the code checks for of course). – Rado May 04 '21 at 19:24
  • @Rado *Checks a zip file to see if its directory is consistent.* is stated as well in their [documentation](https://documentation.help/DotNetZip/a92be548-9551-65b2-e547-fa047c22c00d.htm) as well as: *In cases of data error, the directory within a zip file can get out of synch with the entries in the zip file. This method checks the given zip file and returns true if this has occurred.* – Trevor May 04 '21 at 19:25
  • So no CRC check? – Rado May 04 '21 at 19:27
  • I read this in another post here: "The most complete level does a full extraction of the zip file into a bitbucket to verify that the actual compressed data is not corrupted. " https://stackoverflow.com/questions/3954505/how-to-quickly-check-if-a-zip-file-is-corrupted/4009061#4009061 – Rado May 04 '21 at 19:28
  • 2
    @Rado [have a read](https://github.com/haf/DotNetZip.Semverd/blob/e487179b33a9a0f2631eed5fb04d2c952ea5377a/src/Zip.Shared/ZipFile.Check.cs#L115) there about how the `CheckZip` works. – Trevor May 04 '21 at 19:36

0 Answers0