Temporary file left after manipulating zip file created by DotNetZip

Jul 31, 2012 at 11:01 PM
Edited Jul 31, 2012 at 11:50 PM

I'm creating a zip file using DotNetZip in another application, then manipulating it in another application.  When I zip.Save(), DotNetZip creates a temp file but fails to delete it on zip.Dispose() (or when the using block finishes).

  using (var zip = ZipFile.Read(this.Properties.GetZipPath()))
  {
       zip.CompressionLevel = Ionic.Zlib.CompressionLevel.None;
             
       zip.AddEntry(manifestFilename, Options.SerializeHelper.SerializeToXmlString(this.manifestContents), System.Text.Encoding.UTF8);
       if (zip.ContainsEntry(extraContentFolder))
       {
           zip.AddFiles(this.getExtraContentFiles(), extraContentFolder);
       }
        zip.Save();  // creates temp zip file and saves off changes to original zip
    } // implicit zip.Dispose() - but temp file is not deleted!

This is a representative sample of the block of code that's creating the temp file.  I've tried commenting various lines inside the using {} statement, but DotNetZip consistently leaves the temp file behind if I make any changes to it.

As I mentioned, the source zip file is created using DotNetZip in another application:

using (ZipFile zip = new ZipFile())
{
    zip.AddDirectory(directory.FullName);
    zip.Save(zipFile);
}

 

What's strange is that, if you rebuild the source zip using 7-zip, then the temp files do not appear.  Additionally, I'm doing similar processes (open zip, add files, save zip, dispose) elsewhere in various applications and I'm not seeing this temp file sticking around (I think).

Am I missing some piece of magic here or when I create the source zip files?

Mar 3, 2014 at 2:51 PM
I have the same issue. Did you ever find a solution? I see the project has not been updated. I may have to root around in the code to see if I can find & fix it.
I've tried two variations with the same result:
using (ZipFile zip = new ZipFile())
{
    zip.AddEntry(fileName, content);
    zip.Save(zipFileName);
}
and
using (ZipFile zip = new ZipFile(zipFileName))
{
    zip.AddEntry(fileName, content);
    zip.Save();
}