How would I delete a directory in a .zip and all the files in it (preferably using DotNetZip)?
Right now I'm running through all the files in the zip, but it doesn't work:
foreach (ZipEntry e in zip)
{
//If the file is in the directory I want to delete
if(e.FileName.Substring(0, 9) == "FolderName/")
{
zip.RemoveEntry(e.FileName);
}
}
Is there a better way, if not, how would I make this work?
Here's a simple way to do this:
Documentation here http://dotnetzip.herobo.com/DNZHelp/Index.html
In order to delete the directory and all nested child entries, I used
Note that the path must end with a slash, like
dir/subdir/
First tought. Don't loop with foreach while removing elements from the collection.
I will try in this way
However, looking at the methods of the ZipFile class, I noticed the method: SelectEntries that return a ICollection. So I think it's possible to do:
EDIT: Use overloaded version SelectEntries(string,string)
removing the loop on all entries in the zipfile