2

I need to remove one folder called "META-INF". It contains some files. How can I delete that folder, along with all the files in it, without typing all of their names? I can't extract all the files, delete the directory with all the files, and then pack the zip again, because the zip has many files (~1800).

yoozer8
  • 7,361
  • 7
  • 58
  • 93
GemHunter1
  • 441
  • 1
  • 4
  • 15
  • Is RemoveEntry() not working? Edit: Look at this http://stackoverflow.com/questions/9855155/how-can-i-delete-a-directory-in-a-zip-file-using-net Possible duplicate? – jAC Jan 06 '13 at 15:05
  • Nice to hear that, you're welcome! – jAC Jan 08 '13 at 16:33

2 Answers2

1

I used this:

 int x;
 for (x = 0; x < zip.Count - 1; x++)
 {
     ZipEntry e = zip[x];
     if (e.FileName == "META-INF/")
     {
         zip.RemoveEntry(e.FileName);
     }
 }
GemHunter1
  • 441
  • 1
  • 4
  • 15
0

You can use something like this:

var matches = fileSelector.SelectEntries(yourZipFile,"META-INF");
for(int i = 0;i < matches.Length; ++i)
{
    yourZipFile.RemoveEntry(matches[i].FileName);
}
prthrokz
  • 1,120
  • 8
  • 16