This project is read-only.

File handles persist after calling Dispose() when extracting spanned ZIP

Dec 19, 2010 at 10:11 AM
Edited Dec 19, 2010 at 11:14 PM


Thanks for this very helpful library.

Just ran into an issue when extracting spanned archives created with DotNetZip. My code is written in PowerShell.

Code to create the spanned archive:

$zipfile = new-object Ionic.Zip.ZipFile
$zipfile.UseZip64WhenSaving = [Ionic.Zip.Zip64Option]::AsNecessary
$zipfile.MaxOutputSegmentSize = $archiveSegmentSize # 40MB


Code to extract the spanned archive:

$zip = [Ionic.Zip.ZipFile]::Read($Zipfile.Fullname)
$zip.ExtractExistingFile = [Ionic.Zip.ExtractExistingFileAction]::OverwriteSilently

This will create a spanned archive with say about 5 segments. What I've noticed is that after the spanned archive is extracted, file handles to the archive segments are not closed for most of the segments after calling the Dispose() method. This means the segment files cannot be deleted because they are still in use.

This also seems to be the case when extracting a spanned archive with the DotNetZip-WinFormsTool program.

When I tried the same code to extract a non-spanned ZIP created with DotNetZip, the file handle was closed and I could delete the ZIP file after.


Dec 19, 2010 at 11:53 PM

It looks like the file handles get cleaned up after a bit of time which suggests the garbage collector is doing it. So I've added this to my PowerShell code and it seems to resolve the issue for now:


Dec 21, 2010 at 3:13 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.