How do I remove a specific folder with files in it from a zip using the Dotnetzip library? [duplicate]

StackOverflow https://stackoverflow.com/questions/14183361

  •  13-01-2022
  •  | 
  •  

Frage

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).

War es hilfreich?

Lösung

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);
     }
 }

Andere Tipps

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);
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top