How to force delete a folder used by another process?

Possible duplicate:
How to delete a file used by another process?

I have the following C # code, but it throws an exception when calling 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 a way to get it to delete this directory, even if it is being used by another process?

+4
source share
1 answer

no not stopping another process

+9
source

Source: https://habr.com/ru/post/1438962/


All Articles