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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject.FileExists and UNC Path Problems

Status
Not open for further replies.

NWChowd

Programmer
May 26, 2002
84
US
Hi all,

I am having trouble getting the FileExists method to return true when I pass it a valid UNC Path to a file ("testfile.txt").

background: i have created a virtual directory in IIS 5.0 named "SubmitFiles" on Server1 that points to a directory on another server ("Server2"). I need to check whether a file exists or not before adding a file to the directory.



<%
...

Set objFSO=Server.CreateObject("Scripting.FileSystemObject")

Response.Write Server.MapPath("SubmitFiles\testfile.txt")

Response.Write "<BR><BR>"
IF ObjFSO.FileExists(Server.MapPath"SubmitFiles\TableScripts.sql")) Then
Response.Write "yes, file exists! :)"
Else
Response.Write "no, file does not exist. :-("
End If

set objFSO = Nothing

%>


I am connecting to the SubmitFiles virtual directory with an Administrator account on our network that has basically full access. I have given the directory on "Server2" permissions to the IUSR_Server1 user.

I am at a complete loss as to why the FileExists method is returning false when I know the file does exist..


Any ideas/suggestions??


thanks in advance,
dmill








======================================
&quot;I wish that I may never think the smiles of the great and powerful a sufficient inducement to turn aside from the straight path of honesty and the convictions of my own mind.&quot;
-David Ricardo, classical economist
======================================
 
looks like you're missing a (

IF ObjFSO.FileExists(Server.MapPath("SubmitFiles\TableScripts.sql"))

___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Yes, I definitely had the "(" in my code. must a dropped it during my tinkering with the code. in any case, it still does not work even with the correct syntax (i.e. with the parantheses).


any other suggestions??
thanks.
Dennis

======================================
&quot;I wish that I may never think the smiles of the great and powerful a sufficient inducement to turn aside from the straight path of honesty and the convictions of my own mind.&quot;
-David Ricardo, classical economist
======================================
 
do you generate the path and file with a
Response.Write Server.MapPath("SubmitFiles\TableScripts.sql")



___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
boy, my mistake. sloppiness on my part.

tablescripts.sql is just a test file. it does not execute or anything. so, my example shold loook like:

<%
...

Set objFSO=Server.CreateObject("Scripting.FileSystemObject")

Response.Write Server.MapPath("SubmitFiles\testfile.txt")

Response.Write "<BR><BR>"
IF ObjFSO.FileExists(Server.MapPath"SubmitFiles\testfile.txt")) Then
Response.Write "yes, file exists! "
Else
Response.Write "no, file does not exist. :-("
End If

set objFSO = Nothing

%>


apologies for the confusion.

thanks,
DMill



======================================
&quot;I wish that I may never think the smiles of the great and powerful a sufficient inducement to turn aside from the straight path of honesty and the convictions of my own mind.&quot;
-David Ricardo, classical economist
======================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top