PDA

View Full Version : Issues with the FileSystemObject


oracleguy
03-06-2003, 06:14 AM
Okay I'm using the FSO to load the contents of a text file thats specified by a querystring. And it can use the FSO to see if the file exists and all but when I try to open it, it locks the server up.

Here is my code:

<%Dim strPage
strPage=Request.QueryString("Page")

If strPage="" Then strPage="home.txt"

If strPage<>"" Then strPage=strPage & ".txt"

Dim fso, page
Set fso = Server.CreateObject("Scripting.FileSystemObject")

If fso.FileExists(Server.MapPath(strPage)) Then
'File exists so load it up
Set page=fso.OpenTextFile(Server.MapPath(strPage),1)
Do While page.AtEndOfStream<>True
'Load the file in
Response.Write(page.ReadLine)
Loop
Else
'File doesn't exist
%>
<p style="color: #FF0000;">LINK ERROR. The page you are trying to access does not exist.</p>
<%
End If
%>

I can seem to figure it out. I've used the FSO before and haven't had problems.

Morgoth
03-06-2003, 06:22 AM
Hehe, I had the exact same problem...
I screams and sat in my chair in shock when I finally got it working.

Now, chances are it's the same problem.


String1 = Are you running Norton Anti-Virus?

If String1 = True Or String1 = "Yes" Then
Response.Redirect("http://www.iisfaq.com/default.aspx?View=A387&P=170")
Else
Response.Write "I can't help you"
Response.End
End If

Morgoth
03-06-2003, 06:34 AM
LOL, also

you might want to fix this up dude:

PHP colour codes it..

If strPage="" Then strPage="home.txt"

// 'strPage NOW = "home.txt" Because page=""

If strPage<>"" Then strPage=strPage & ".txt"
// 'strPage<>nothing so you just made strPage = "home.txt.txt"



Either do this (FLIP):

If strPage<>"" Then strPage=strPage & ".txt"
If strPage="" Then strPage="home.txt"


Or better yet, try to keep it easier to read (which will prevent that problem above from happening again):

If strPage="" Then
strPage="home.txt"
ElseIf strPage<>"" Then
strPage= strPage & ".txt"
End If


UNRELATED: (I think WA should take the PHP function, copy it, and change just the name of the tags and name of the title to ASP.)

oracleguy
03-06-2003, 06:40 AM
Doh! I even had that bookmarked! That cleared it right up.

And thanks for catching my other error. It was cleaner but then i started ripping it up trying to solve the FSO problem.

Morgoth
03-06-2003, 07:36 AM
:thumbsup:

whammy
03-07-2003, 01:36 AM
Ya know, Morgoth, I've thought of the same thing myself... the PHP syntax coloring would be fine for ASP (perhaps even javascript?).

I bet the forum code could be easily altered to allow this functionality, even if we had to manually type into the brackets... but it's confusing to newbies if it says "PHP:".

Morgoth
03-07-2003, 01:51 AM
Very much so..

You have MOD powers, why not send WA an e-mail or something?

oracleguy
03-07-2003, 02:09 AM
Yeah that would be a good idea. Come in real handy.

whammy
03-07-2003, 02:11 AM
Well, with that kind of support, I'll definitely show him this thread! :)

whammy
03-07-2003, 02:16 AM
Ok, I created a post in the TOP SECRET room referencing this thread, and we'll see what WA says. :)

I think it would be really handy for not only the ASP forum, but the javascript forum as well...

Morgoth
03-07-2003, 03:36 AM
So WA is going to read this?

HEY WA!