6

Possible Duplicate:
How can I delete a file that is in use by another process?

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:

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?

Community
  • 1
  • 1
DiverseAndRemote.com
  • 19,314
  • 10
  • 61
  • 70
  • Check this question: http://stackoverflow.com/questions/5232647/how-can-i-delete-a-file-that-is-in-use-by-another-process – kmatyaszek Oct 10 '12 at 16:18

1 Answers1

10

no, not without stopping the other process

paul
  • 21,653
  • 1
  • 53
  • 54