Conversation
|
Force pushed the wrong branch, whoops. |
intbeam
left a comment
There was a problem hiding this comment.
Checking if a file exists using File.Exists may cause unintended behavior because you can't know if the file gets immediately deleted between File.Exists and new FileStream (no matter how unlikely)
Use a try-catch for this specific type of issue, and only catch the specific exception (and not anything and especially not everything else)
try
{
}
catch(System.IO.FileNotFoundException ex)
{
}CheckIfFileExists is a property on that class that affects the behavior of ShowDialog(), it doesn't do anything on its own. It prevents the user from entering a filename into the file text box that does not exist, so that should probably be set to true
|
If the user deletes the file in the 50 microseconds between the |
The previous code was using a configuration property to check if the file exists, which would always pass because it defaults to
true.