justuptime.com - monitor your servers & websites

text stream object not working on local server

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.
akohl's picture

They have: 117 posts

Joined: Feb 2001

Having trouble getting text stream object to work on local server
The following code results in no response to the browser and subsequent requests to the website after this code is run also get no response from the website untill iis is reset. What might my problem be?

the set ObjectTextS line is the culprit.

When commented out the browser gets a response.

What might be the problem?

<% @ language= vbscript %>
<% option explicit
%>
<html>
<head>
<title>
data fill asp page
</title>
</head>
<body>
<%
dim out
const forReading=1
const forWriting=2
const forAppending=8
const tristateUseDefault=-2
const tristateTrue=-1
const TristateFalse=0
dim objFs, objTextS, page, file
dim strLine
page="items.txt"
file="c:\webtexts\"&page
set objFs=server.CreateObject("scripting.fileSystemObject")
if objFs.fileExists(file)=true then
response.write "<p>file exists</p>"
set ObjTextS=objFs.openTextFile(file,forReading,tristateFalse)
strLine= objTextS.readLine
response.write ("<p>here is the line...</p><p> "&strLine&"</p>")
objTextS.close
set objTextS=nothing
else
response.write "<p>file does not exists</p>"
end if

set objFs=nothing
response.write("<h1>hi from datafill</h1>")
%>

'

Andy Kohlenberg
Efrat, Israel

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Make sure the IUSR_machinename account has access to whatever directories you're going to be using. Also make sure you don't have any anti-virus software on your server that might block scripting access to directories.

Other than that, your code looks fine.

PJ | Are we there yet?
pjboettcher.com