ASP FileSystem Object

T

TOP

tried to do the following:

<html>
<body>
<p>This is the test</p>
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
set fso = server.CreateObject("Scripting.FileSystemObject")
set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")
set ts = f.OpenAsTextStream(ForReading, -2)
TextStreamTest = ts.ReadLine
Do While not ts.AtEndOfStream
myText = myText & ts.ReadLine & vbCrLf
Loop
response.write(myText)
%>
</body>
</html>

but it did not work on any machine. - I have IIS 5.1, .Net Framework 1.1,
but IIS hangs up, Ihave to kill the IIS process, stop and restart does not
work. All Userrights are set for the IUSR_Machine UserID on the directory. I
have no idea why I fail, it worked fine in the past but I guess it was IIS
4.0 and no .Net Framework. By the way D:\WWWHosting\site is the root of the
Site

Does anybody has an idea ????

Please help!


--


Mit freundlichen Grüßen

Thomas Pecha
 
S

Steven Burn

Try;

<%
Public Const ForReading = 1, ForWriting = 2, ForAppending = 8
set fso = server.CreateObject("Scripting.FileSystemObject")
set f = fso.GetFile(Server.MapPath("/test/testread.txt"))
set ts = f.OpenAsTextStream(ForReading, -2)
TextStreamTest = ts.ReadLine
Do While not ts.AtEndOfStream
myText = myText & ts.ReadLine & vbCrLf
Loop
response.write(myText)
%>


--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
S

Steven Burn

Below is the code I wrote for one of my clients site's........, might want
to verify it against yours?

<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
strFile = Server.MapPath("input_file.txt")
Set OutputStream = FileObject.OpenTextFile (strFile, ForAppending, True)
OutputStream.WriteLine "Date : " + cstr(Now())
OutputStream.Close
Set OutputStream = Nothing
Set FileObject = Nothing
%>

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
J

Jeff Cochran

tried to do the following:

<html>
<body>
<p>This is the test</p>
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
set fso = server.CreateObject("Scripting.FileSystemObject")
set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")
set ts = f.OpenAsTextStream(ForReading, -2)
TextStreamTest = ts.ReadLine
Do While not ts.AtEndOfStream
myText = myText & ts.ReadLine & vbCrLf
Loop
response.write(myText)
%>
</body>
</html>

but it did not work on any machine.

Did not work? How do you know? What *did* happen? Is the file where
you think it is?

Jeff


- I have IIS 5.1, .Net Framework 1.1,
 
T

TOP

I logged into a mdb therfore I know that it does work until

set f = fso.GetFile("D:\WWWHosting\site\test\testread.txt")

That means creating the fso is fine then it stopps and IIS hangs up.

To all the guys trying to help with coding: I all tried this already -
sorry - it also works with server.mappath the samme way, means the path is
correct.
 
T

TOP

stays the same

it stops after creating the fso, I know that becaus I am logging int a mdb
(which works fine)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top