Reputation: 51084
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.
Upvotes: 1
Views: 1195
Reputation: 33474
What is the debug time value of the variable "folder"? Is it a folder which exists outside of website directory?
Upvotes: 0
Reputation: 52198
Is it possible to do a proc mon on asp.net worker process and verify if it is actually checking for the existence of that particular folder? Check for the result codes too to troubleshoot any access denied errors.
Upvotes: 3
Reputation: 59513
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.
Upvotes: 5