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?