Ionic.FileSelector.SelectEntries() can't return child folder entries?

Oct 11, 2010 at 6:43 PM
Edited Oct 11, 2010 at 8:34 PM

If i just do

ICollection<ZipEntry> results = selector.SelectEntries(zip);

I get all entries in the zip even entries that represent empty folders.  Seems to me it's the equivalent of specifying a starting path of "\\" or root. 

But if I try to retrieve entries that represent empty folders _starting from a certain path in the archive_  then it doesn't work.  It works for *.* and returning file entries, but not directory entries.  This seems like a bug to me.

If I  try something like

ICollection<ZipEntry> results = selector.SelectEntries(zip, "vehicles\\")

where sub folder entities I expect to get back are






But none of the above sub entries are returned.




Oct 11, 2010 at 7:17 PM
Edited Oct 11, 2010 at 8:42 PM

I peeked at the code inside FileSelector.SelectEntries  and i see why it doesnt work.

instead ead of searching for the exact dir match you can just


foreach (entry in zip.Entries)


    string entryDir = Path.GetDirectoryName(entry.FileName);  // let's say entry.FileName =  "vehicles/cars/"  then this will result in entryDir = "vehicles\\cars"

    if (entryDir != startPath && startPath == Path.GetDirectoryName (entryDir))  // second call of GetDirectoryName on entryDir strips off another dir layer so now we compare with startPath to know if this is a first level child under the startpath


Oct 14, 2010 at 3:06 AM

I didn't have the best understanding of the zip format in the beginning but now I understand how "directories" inside a zip work.  For instance I was surprised to find that if you had an empty zip

and you added an empty folder called \\vehicles\\cars

and then a file \\vehicles\\cars\\viper.obj

you'd have 2 zip entries.

However again starting with an empty zip and this time only adding


would result in just one zip entry with no separate directory entry for  \\vehicles\\cars\\  in addition to the viper.obj  entry.




Oct 14, 2010 at 8:35 PM

Yes, that's correct: directory entries within a zip file are not container objects. And, there's no requirement for a directory entry to exist in the zip, if a file object exists that would occupy that directory if extracted.

So, give your new understanding, is there still a question, or a problem?