This is my code to update an existing zip, the callers pass in the ZipFile and have a finally block to close the zipfile.
private static void AddFiles(ZipFile zipFile, string path, string filesEntryLocation, string pattern = @"*") {
zipFile.BeginUpdate();
string[] files = Directory.GetFiles(path, pattern);
foreach (string filename in files) {
zipFile.Add(filename, (filesEntryLocation + filename.Split(new[] { '\\' }).Last()).Replace('\\','/'));
}
zipFile.CommitUpdate();
}
As you can see I'm adding entries into the zip and setting the entryname to be in a specific part of the zip folder hierarchy.
We are doing this to inject a product into a 'framework' web package - the framework supports loosely coupled products.
The result zip is fine, I can navigate it in Windows, I can extract it... BUT MSDeploy comes along and where ever a new entry resulted in an addition to zip folder hierarchy, I get errors from msdeploy saying it couldn't open the zip - BUT only at that specific i.e. the zip is not completely corrupt, it's only where msdeploy starts navigating done a 'new' folder.
Now, if I extract the changed zip, and then re-zip it (using 7zip), and ask msdeploy to execute against that - no problem it works.
SO - is this SharpZipLib, or am I doing something wrong in adding to the zip folder hierarchy?