In my program I need to be able to delete the directory with the old output. But some files inside it might be locked. In this case, I want to warn the user that he needs to close the applications that lock them before the program can proceed, with a Retry/Cancel dialog, and if the user clicks Cancel, I want the directory to stay intact.
So, can anyone tell me of a way to check if an entire directory tree can be deleted (no locked files in any subdirectories), without modifying its contents – something like a dry-run.
Maybe you could try and rename the parent directory, in Windows at least you would get an error saying it is not possible if a file in a subfolder is locked. If rename succeeds it should be safe to delete and prevents others of accessing the tree before you delete it.