If I have a metro StorageFolder, I can get a file using GetFileAsync(fileName).
However, how do I know if the file exists in the first place? Right now, I catch an exception but it does not seem like the right thing to do.
According to Microsoft, they want us to catch the exception. The reasoning they gave me is that them providing a File.Exists API would open you up to race conditions where the file's existance might change between when you check and when you try to use the file. Because of that race condition, you have to write exception handling code anyways and once you've done that, there's little to be gained by calling a File.Exists API. I don't agree with this argument but it's what we're stuck with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With