• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Any ASP/VBScript experts around?

Status
Not open for further replies.

snapty00

Banned
Is there any reason why this shouldn't work?

Code:
<%
set newsNAME=request.querystring("fileindex")
set fs=Server.CreateObject("Scripting.FileSystemObject")
If newsNAME <> "" And fs.FileExists("news.asp")=true Then
	set f=fs.OpenTextFile(Server.MapPath("newsdocs/" & newsNAME & ".txt"),1)
Else
	set f=fs.OpenTextFile(Server.MapPath("newsnotfound.txt"),1)
End If
%>

The problem: the code fragment fs.FileExists("news.asp")=true *ALWAYS* evaluates to false, so it always goes to the ELSE statement. And yes, "news.asp" exists in the same directory as the script itself, so that's not the problem. :p Anything else obvious that I've got wrong? Thanks.
 

dog$

Hates quality gaming
All the examples I found online make it look like this should work. It didn't when I tried it on my brower, though.

I'm wondering if you net a .GetFile function in there to get news.asp "avialable" to be checked for existing or something. I don't know why it doesn't work, myself. I couldn't get it to find anything...
 

8bit

Knows the Score
I'd try fully qualifying the path(Server.mappath if you need it).

Don't assume the runtime will inherit the path of the running script.
 
Status
Not open for further replies.
Top Bottom