我创建了一个删除文件夹的程序。像这样 :
if (Directory.Exists((System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "My Dir Name"))))
{
Directory.Delete(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "My Dir Name"), true);
}
这没关系。但是名称为“Delete.exe”的文件位于“我的目录名称”[Like my code] 的目录中!它给出了一个错误,因为“Delete.exe”正在运行并且无法删除。
我该怎么做才能删除“Delete.exe”?