0

I have been using DotNetZip successfully so far, but now I've run into a hiccup. I'm wondering if I'm just missing something and this is expected behavior or if this is actually a bug.

I use the following simple code to iterate through all files within a Zip:

using (ZipFile zip = ZipFile.Read(filepath))
{
    foreach (ZipEntry content in zip)
    {
        // do stuff
    }
}

This seemed to work fine, it iterates through all files and folders within the zip. But now I've come across a Zip in which this iteration skips the folders inside the zip. If I check the entries property of the ZipFile, it does indeed not contain the folders. So it's not the iteration that's causing problems, the ZipFile itself seems to be read wrong. If I check it with FileZip.CheckZip(...) all seems fine and FileZip.FixZipDirectory(...) does not help either. The Zip seems okay if opened with 7zip etc.

Edit: Okay, it seems to be some kind of problem with the zip. I unzipped it and rezipped and now the entries list has all the folders. Unfortunately, I cannot influence which zips get scanned with this algorithm. If anyone could point me to a possible way to detect or handle such faulty zips, that'd be great. Currently the only way I can think of is getting all the folder names from the file entry names (which contain the folder name as a prefix).

janb
  • 360
  • 5
  • 16

0 Answers0