0

I have a password protected zipped file which contains another pw zipped file and I want to retrieve a xml file under a folder 0 inside the second zip. But I would like to have this xml in the root folder (args[0]), Do you have an idea ?

It is always extracting in root/0/project.xml and I want root/project.xml actually I want the xml in the same folder than the first zip.

using (ZipFile zip = ZipFile.Read(args[0])) {

     zip.Password = "pass1";
     zip.ExtractAll(".",ExtractExistingFileAction.OverwriteSilently);
     using (ZipFile zip2 = ZipFile.Read("0.xtz"))
     {
          ZipEntry e = zip2["0/project.xml"];
          e.ExtractWithPassword(".", ExtractExistingFileAction.OverwriteSilently, "pass2");

     }

}
xenom
  • 377
  • 1
  • 5
  • 15

2 Answers2

0

set the FlattenFoldersOnExtract property to true for the ZipFile

Anya Shenanigans
  • 91,618
  • 3
  • 107
  • 122
0

I found a particular answer in my case. If you know the name of the file, the trick is to keep only the filename

ZipEntry e = zip2["0/project.xml"];
e.Filename="project.xml"
e.ExtractWithPassword(".", ExtractExistingFileAction.OverwriteSilently, "pass2");

You can also make a loop if you have several entries to remove any folder containing "/" and keep the filename only.

xenom
  • 377
  • 1
  • 5
  • 15