Re: Can't determine if a file exists

From: Nicole Calinoiu (calinoiu)
Date: 08/12/05

Date: Fri, 12 Aug 2005 07:40:07 -0400

"Nikolai Evseev" <> wrote in message
> Hi there,
> I am usign System.IO.File.Exists in my ASP.NET code to determine if a file
> exists in the specified location. The webserver is my local machine, which
> is
> a part of the corporate domain. The file the existence of which I am
> trying
> to determine is sitting in the shared folder of the PC which is not a part
> of
> the corporate domain. If the Authenitcation on my webserver allows
> Anonymous
> user to logon then Exists method returns false (I take it happens because
> my
> anonymous user doesn't have access to that shared folder, since it's not a
> part of the domain).

Since ASP.NET is supposedly running on the same machine as the target
folder, the domain issue shouldn't be relevant for the anonymous scenario.
Are you using a local path to attempt to access the file (e.g.:
"c:\somefolder\somefile.txt" instead of
\\yourmachine\sharename\somefile.txt)? If so, you'll need to grant at least
the "List Folder/Read Data" permission on the folder containing the file to
the user account under which your application is running. (If you haven't
fiddled with the ASP.NET process account or impersonation settings, this
will be the ASPNET user on Windows XP when the application is using
anonymous access.) If you're not using a local path, try switching to that

> If I am using windows authentication then everything
> works fine, and I am able to see if the file exists in the shared folder.

Presumably because your account has permissions to the file.

> The
> last one, though, only works if I open the browser on the same PC where my
> webserver is running. But if I am logged on using the same user name and
> password on another PC then again Exists method always returns false.

Hmm... Now I'm starting to wonder if the "shared folder" is really local to
your PC or not. Could you please confirm if it's truly local to your PC or
if it's actually pointing to a share on another machine?

> I know it's a little confusing but still hoping that you can help me
> solving
> this problem
> Thanks