如何强制删除文件夹被另一个进程? [英] How do I force delete a folder being used by another process?

查看:571
本文介绍了如何强制删除文件夹被另一个进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/5232647/how-can-i-delete-a-file-that-is-in-use-by-another-process">How我可以删除一个文件,该文件是由另一个进程使用?

我有以下的C#code,但它抛出在调用Delete方法异常:

I have the following c# code but it throws an exception on the call to the Delete method:

var dir = new DirectoryInfo(@"C:\mydirectory\");
dir.Delete(true);

下面抛出异常:

The following exception is thrown:

该进程无法访问该文件'C:\ mydirectory,因为它正由另一个进程使用

The process cannot access the file 'C:\mydirectory' because it is being used by another process.

有没有什么办法,迫使它删除这个目录,即使它正在被其它进程?

Is there any way to force it to delete this directory even though it's being used by another process?

推荐答案

没有,不是没有停止其他进程

no, not without stopping the other process

这篇关于如何强制删除文件夹被另一个进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆