I tried to use the files inside a zip unlocked with ionic.zip in C#
I do that using
string zipToUnpack = filename;
ExtractFileToDirectory(filename,appPath);
First time it works fine, but then I try a second time and I get an IO exception saying the file is been used by another user. How can I unlocked this file from the current process?
I cannot seem to find ExtractFileToDirectory
in Ionic.Zip's reference documentation . I did find a function with the same name in another StackOverflow question, "Extract a ZIP file programmatically by DotNetZip library?" . If that is the implementation that you are using, you probably need to call Dispose
on the ZipFile
to close the underlying file streams.
public void ExtractFileToDirectory(string zipFileName, string outputDirectory)
{
using (ZipFile zip = ZipFile.Read(zipFileName))
{
Directory.CreateDirectory(outputDirectory);
zip.ExtractAll(outputDirectory,ExtractExistingFileAction.OverwriteSilently);
}
}
If not, share more details about how you are extracting the files.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.