Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File.Exists(path) returns false on webserver and true on localhost

Status
Not open for further replies.

Alcar

Programmer
Sep 10, 2001
595
US
Hi,

I am using File.Exists(path) method to determine if a file exists. Locally it works perfectly, but when I deploy it (project-Copy) on the webserver, it doesn't.

Code:
string strPath = @&quot;\\<DFS Folder>\<Filename>&quot;;
if(File.Exists(strPath))
{
  // YUPPPIEEEE!
}
else
{
  // NOT A CHANCE!
}

given that both IIS have the same permissions, when I run the program lcally (debug mode) the method returns true, when I run it off the server it returns false.

I have also tried different tests:

path local webserver
-----------------------------------------------------------
\\<dfs servername>\<filename> true false
c:\temp\<filename> true true
o:\temp\<filename> true false
(where o: maps a folder in another server <> webserver)

After alot of research I decided to follow what Microsoft suggests:

Code:
FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Read, <path>);

But this didn't change a thing.... any ideas?

Daren J. Lahey
Just another computer guy...
FAQ183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
Support your forums TODAY!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top