2
Vote

SevenZipExtractor doesn't release file handle on retry

description

When constructing a new SevenZipExtractor(file_path) with either a file path or a stream, how do you release the file handles if ExtractArchive fails?
 
ProcessExplorer shows that SevenZip still has handles to [the files within the archive] and retrying ExtractArchive (e.g. with pwd) throws "The process cannot access the file {one of the files in archive} because it is being used by another process".
 
Disposing doesn't release the handles. Is there a way to let go of the files or is this a bug?
I could not find an answer in .chm file.
 
Code sample:

try
{
using (SevenZipExtractor sevenZipExtractor = new SevenZipExtractor(source_path))
{
    sevenZipExtractor.ExtractArchive(extractDirectory);
}
}
catch (SevenZip.ExtractionFailedException)
{
//file handles in archive are not released so you can't try again
using (SevenZipExtractor sevenZipExtractor = new SevenZipExtractor(source_path, pwd))
{
    sevenZipExtractor.ExtractArchive(extractDirectory);
}
}
 

"The process cannot access the file {one of the files in archive} because it is being used by another process".
 
Thank you.

comments