Top-level folder not appearing as ZipEntry within zip file

Jun 18, 2013 at 12:28 AM
I'm seeing some odd behavior when I try to read a zip file and enumerate the contents. I'm using Visual Basic 10 on Windows 7, and Ionic.Zip.Reduced.dll version

Basically DNZ doesn't recognize folders in the top level of the zip file. It recognizes the files within them, and also the subfolders within them and the files within those subfolders.

Say I have file structured like this:

File1 at the top level
File2 at the top level
FolderA at the top level containing
FolderB at the top level containing
FolderB2 at the next level containing
  - File5
Running this VB code:
  Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
    Dim e As ZipEntry
    For Each e In zip1
  End Using
will return info on all five files, and FolderB2; but not FolderA or FolderB.
I would like to return as a ZipEntry each of those two missing folders at the top level, as well as what presently appears.
Any ideas?
Jun 25, 2013 at 4:08 PM
I ran into the same issue, and it appears to be related to how Windows creates zip files. I took a known-working zip file that I'd previously parsed correctly (ie top-level folders were listed as a ZipEntry), extracted it and re-zipped using Windows' own compression tool. On trying to parse this file, there were no top-level directories listed as a ZipEntry. Re-zipping the same folder with WinRar again gave me a correctly-parseable archive.
Jun 25, 2013 at 9:44 PM
Thanks! Yes, I think you are right. I found a workaround, which is to extract everything to a temporary folder and traverse that (recursively, in case there are any zip files at a lower level). In some cases that might be a burden, but in this one it works well since I may need to open the lower levels.