When determining whether or not a file exists, how does using the try statement avoid a \"race condition\"?
I\'m asking because a highly upvoted answer (update: it w
I think what you're asking is the particular race condition where:
The way you're "protected" in this case is by putting all the file handling code in a try block, if at any point the file becomes inaccessible/corrupt your file operations will be able to fail "gracefully" via the catch block.
Note of course modern OS's this can't happen anyway, when a file is "deleted" the delete won't take place until all open handles on the file are resolved (released)