I’m getting an intermittent false negative on the following line of code in an ASP.NET 2 web site:
if (!System.IO.Directory.Exists(folder))
The folder clearly exists, and even contains a log file that is written to when the CLR doesn’t lie about the folder’s existence. Any help would be appreciated.
Exists() returns false, rather than throwing an error, if any sort of IO error occurs. One thing to watch out for is security errors. Exists does not perform network authentication, so it requires being pre-authenticated if your accessing a network share, at least according to the docs. I haven’t tried it myself.