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

cannot open an existing file

Status
Not open for further replies.

jw424

Programmer
Aug 7, 2001
8
US
Hi,

I have an asp page which needs to open an existing file for reading. But I always get an error saying the file does not exist.

Here's my code:

<%
dim oFS
set oFS = Server.CreateObject (&quot;Scripting.FileSystemObject&quot;)
dim text
set text = oFS.OpenTextFile (&quot;Config/test.txt&quot;)
%>

Config and the asp page reside in the same directory.

Any suggestions???

thanks
 
You need to pass the absolute path to .OpenTextFile...

Server.MapPath will map out the absolute path to any file that you specify, provided it's in your somewhere.

this will work for you...
<%
dim oFS, map
map = Server.MapPath(&quot;Config/test.txt&quot;) 'assuming Config is at
set oFS = Server.CreateObject (&quot;Scripting.FileSystemObject&quot;)
dim text
set text = oFS.OpenTextFile (map)

response.write map 'just so you see what it gives you...
%>

hth
leo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top