Multi-Span Zips not closing after ZipFile disposal

Jun 1, 2010 at 8:49 AM
Edited Jun 1, 2010 at 8:54 AM
Hi Cheeso,
Reposting from the 'C++/CLI and "using" keyword' thread, as requested!

I'm using DotNetZip in a C++/CLI project to create encrypted and potentially multi-spanned archives, which are written to CD (hence the multi-spanning). I also have a small app that auto-launches from the first CD, collates the fragments to a directory on the recipient machine's hard-drive, requests the password and decrypts the archive, attempting to clear up the zip fragments after the extraction is complete.

I'm getting an exception when deleting the spanned zip files after extracting, with the error text as follows:
"The process cannot access the file 'xxxx.z01' because it is being used by another process."

I'm using Ionic.Zip.Reduced.dll v1.9.1.5, on WindowsXP
The code is broadly as follows:
...
ZipFile^ zip;
try
{
    zip = ZipFile::Read(sourcePath);
    zip->Password = password;
    zip->ExtractAll(extractPath, ExtractExistingFileAction::OverwriteSilently);
}
catch(...)
{
}
finally
{
    delete zip;
}

try
{
    Directory::Delete(sourcePath);
}
catch(Exception^ ex)
{
}
...


Couple of notes:
1) I've used 'delete zip' rather than 'zip->~ZipFile()' as this has the same effect and is more idiomatic for C++. (I tried zip->~ZipFile() just incase, but get the same results.)
2) If the zip is a single span, it deletes just fine.
2a) To test, I took out the 'delete zip', and I then get the exception even for single span archives, as you might expect!
3) In Windows Explorer I can not delete any of the zip fragments until the extraction application exits.

So, I was wondering if the Dispose method fails to close the zip fragments when dealing with a multi-span archive?
Coordinator
Jun 1, 2010 at 12:56 PM

Hmmm, interesting.  The diagnosis you suggest is possible - I'll investigate.  

It would be surprising because there are test cases tht cover multi-segment archives, and I believe those tests delete the zip file after use.

It won't be hard for me to test it, though.  I'll get back to you.

 

Coordinator
Jun 1, 2010 at 3:04 PM

I've reproduced the behavior.  Will let you know. . .

Coordinator
Jun 1, 2010 at 3:04 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jun 2, 2010 at 7:08 PM
I'm testing a fix for the problem now. . .
Jun 3, 2010 at 1:47 PM

Thanks for the update, your dedication to this project does you proud!

Sep 3, 2010 at 10:51 AM

Anything new about this? I'm struggling with this as well

Sep 7, 2010 at 10:42 AM

bump...

Coordinator
Aug 6, 2011 at 2:03 PM

This was a problem in the v1.9.1.5 release.  It's fixed in the v1.9.1.7 release.  Try it.