1

My zip file has two levels of directory structure. I added a new directory at the root using AddDirectoryByName. Is it possible to move existing directories into the newly create directory? I like to have the zip file containing 3 levels of directory structure without extracting the zip file.

Current Archive:

RootFolder -
           + TopFolder -
                       + SecondFolder

Updated Archive file:

RootFolder -
           + NewFolder -
                       + TopFolder -
                                   + SecondFolder
Magnus
  • 45,362
  • 8
  • 80
  • 118
  • Without going into too much detail. If you're just avoiding Disk IO, I believe that it is possible to use .net zip to extract items into a `MemoryStream` and then to put them back into the zip file. – Sam I am says Reinstate Monica Jan 24 '13 at 17:41
  • Thanks for your reply. I would like to avoid extracting a 500mb file just to add a directly for speed. – user2008421 Jan 24 '13 at 17:46

1 Answers1

3

I figured it out. I just had to modify the FileName in all entries.

using (ZipFile oZip = ZipFile.Read(sFileZip))
{
     for (int iIdx = 0; iIdx < oZip.Entries.Count; iIdx++)
     {
           string sTmpFileName = oZip[iIdx].FileName;
           oZip[iIdx].FileName = "NewFolder/" + sTmpFileName;
     }
     oZip.Save();
}