我使用NUnrar库提取.rar文件。下面的代码工作正常,但我不能删除.rar提取后的压缩文件。
path = Application.StartupPath + @"\updaterapor.rar";
RarArchive archive = RarArchive.Open(path);
foreach (RarArchiveEntry entry in archive.Entries)
{
try
{
string fileName = Path.GetFileName(entry.FilePath);
string rootToFile = Path.GetFullPath(entry.FilePath).Replace(fileName, "");
if (!Directory.Exists(rootToFile))
{
Directory.CreateDirectory(rootToFile);
}
entry.WriteToFile(rootToFile + fileName, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
catch (Exception ex)
{
//hata
}
}
System.IO.File.Delete(Application.StartupPath + @"\updaterapor.rar");
当我尝试使用System.IO.File.Delete(Application.StartupPath + @"\updaterapor.rar");
时出现此错误。 An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll. and says the process already running.
我该如何解决这个问题?