我正在使用 SharpZipLib 中的 FastZip 类创建一个 zip 文件,一旦我关闭程序后,我就无法删除该文件,因为:
“无法删除 zip.zip:它正被其他人或程序使用。关闭所有可能正在使用该文件的程序,然后重试。”
生成文件的代码就是这样的:
fZip.CreateEmptyDirectories = true;
fZip.CreateZip(filesPath + "\\" + this.zipName, filesPath, false, this.zipFilter);
我尝试使用:
using (FastZip fZip = new FastZip())
{
try
{
fZip.CreateEmptyDirectories = true;
fZip.CreateZip(filesPath + "\\" + this.zipName, filesPath, false, this.zipFilter);
}
catch (Exception)
{
}
}
但它不会转换为 iDisposable