ProfK
ProfK

Reputation: 51084

System.IO.Directory.Exists is giving an intermittent false negative

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

Answers (3)

shahkalpesh
shahkalpesh

Reputation: 33474

What is the debug time value of the variable "folder"? Is it a folder which exists outside of website directory?

Upvotes: 0

Gulzar Nazim
Gulzar Nazim

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

Jeffrey L Whitledge
Jeffrey L Whitledge

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

Related Questions