compact framework - List All Files in a Directory using Dot Net Zip? -


Can the dot net be used to list all the names of files in any specific directory anyway? For example, I can specify Directory1 and get File3 and File4.

  ZipFile ------- File1 File2 Directory1 File3 File4 Directory2 File5 File6  

Only entries in the zipfile object, entries are sorted and entries are filenames ...

Anyone?, Cheeso? :)

No, and yes. Although there are no entries in the directory collection, it is a simple matter of string comparison for selecting "related" entries in a particular directory.

In LINQ it looks like:

  var selection = zip Entries where e.FileName.Starts with (directoryName) selection e;  

In the loop, it looks like:

  var list = new list> ZIP Entry & gt; (); Foreach (var in zip.Entries) {if (e.FileName.StartsWith (directoryName)) {list.Add (e); }}  

Edit

You may have to convert to case sensitivity on windows, the case is not meaningful in file names.

Further explanation: Zip format does not treat the directory entry in the zip file as a container, there is no container connection between directory entries and file entries. The only way to know if a file entry is "in a particular directory" is to check the full name of the file entry, if the name of the entry begins with the name of the directory in question, the entry is "in" in the directory < / P>


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -