tags:

views:

670

answers:

3

I’m getting an intermittent false negative on the call “if (!System.IO.Directory.Exists(folder))” in code in an ASP.NET 2 web site [1]. 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.

[1] BugTracker.NET

+5  A: 

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.

Jeffrey L Whitledge
Funny enough that folder was shared, although I didn't set sharing on it. Maybe adding an IIS user implied it should be shared, and it just did it? When I try to stop sharing, the progress dialogue just hangs.
ProfK
+3  A: 

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.

Gulzar
My problem is I can't reliably reproduce the error. It only occurs sometimes.
ProfK
A: 

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

shahkalpesh
It exists as a child of the web site directory.
ProfK