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
{
File::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.