Process locks a folder

Posted by Vad on Stack Overflow See other posts from Stack Overflow or by Vad
Published on 2012-11-14T02:17:00Z Indexed on 2012/11/14 5:00 UTC
Read the original article Hit count: 139

Filed under:
|

Have pretty odd situation. There are 2 applications:

1) C:\MyFolder1\First.exe

2) C:\MyFolder2\Second.exe

First.exe runs Second.exe and quits.

Process.Start(@"C:\MyFolder2\Second.exe");

// And exit.

Seconds.exe waits a few seconds and tries to remove "C:\MyFolder1\" folder.

// Wait for 5 seconds - First.exe terminated by that time for 100%

Directory.Delete(@"C:\MyFolder1\", true);

Action fails with “The process cannot access the file ‘C:\MyFolder1\’ because it is being used by another process.” It's able to remove the First.exe file (actually all files in the folder), but not the folder itself.

Does anybody have an idea why the folder is locked by the second process?

© Stack Overflow or respective owner

Related posts about c#

Related posts about process