This project is read-only.


Multi-Span Zips not closing after ZipFile disposal


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;
zip = ZipFile::Read(sourcePath);
zip->Password = password;
zip->ExtractAll(extractPath, ExtractExistingFileAction::OverwriteSilently);
delete zip;
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.
Closed Jun 15, 2011 at 8:05 PM by Cheeso
this is fixed in changeset 79174. The first binary to get this fix is v1.9.1.6.


Cheeso wrote Jun 2, 2010 at 8:21 PM

I'm testing a fix for this.

fdcgsf wrote Sep 3, 2010 at 11:34 AM

Anything new about this issue? I have the exact same problem. It seems the Dispose() on the ZipFile object has a bug.

        Dim strFile As String = "C:\zipped\"  '<--- zip file has been split using the MaxOutputSegmentSize property
        Dim zip1 As Ionic.Zip.ZipFile = Ionic.Zip.ZipFile.Read(strFile)
        Dim e As Ionic.Zip.ZipEntry
        For Each e In zip1
            e.Extract("C:\unzipped", Ionic.Zip.ExtractExistingFileAction.OverwriteSilently)

        zip1 = Nothing
        Kill(strFile)  '<---- The process cannot access the file because it is being used by another process error...

    Catch ex As Exception
    End Try

rsbra wrote Jan 28, 2011 at 6:35 PM

Any movement of this ioexception error file is in use issue? Having the same issue:
     _sZipFile "c:\temp\"
     main.sBaseDir = "d:\data"
     _iZipCnt = ZipFile.Read(_sZipFile).Count
     Using zip1 As ZipFile = ZipFile.Read(_sZipFile)
        Dim e As ZipEntry
        _iCntr2 = 0
        For Each e In zip1
           _iCntr2 += 1
           e.Extract(main.sBaseDir & "\temp", ExtractExistingFileAction.OverwriteSilently)
           main.tboxStatus.Text = "Unpacking Invoice file " & e.FileName & " from " & System.IO.Path.GetFileName(_sZipFile)
           main.ProgBar1.Value = Int((_iCntr2 / _iZipCnt) * 100)
           main.lblProgBar1.Text = main.ProgBar1.Value.ToString & "%"
     End Using

     ' Move Zip File to Done
     System.IO.Directory.CreateDirectory(main.sBaseDir & "\done\")
     _sDoneFile = main.sBaseDir & "\done\" & Microsoft.VisualBasic.Format(Now, "yyyyMMdd-hhmm-") & System.IO.Path.GetFileName(_sZipFile)
     System.IO.File.Copy(_sZipFile, _sDoneFile)
     If System.IO.File.Exists(_sDoneFile) Then
        System.IO.File.Delete(_sZipFile)           <=========   Herer is where I get the error
     End If

wrote Jun 14, 2011 at 5:41 AM

wrote Jun 15, 2011 at 8:05 PM

wrote Feb 22, 2013 at 2:43 AM

wrote May 16, 2013 at 1:31 PM