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

Reading text into a string

Status
Not open for further replies.

inqbus

Programmer
Apr 9, 2001
18
NZ
Mornin,
Im in confsion on how to open Myfile.txt, then read it into a big string that I can then display on my page.

This is where Im at:
<%
Dim fso, f, ts
MyFile = FreeFile

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set MyFile = fso_OpenTextFile(&quot;MyFile.txt&quot;, 1, True)

Do Until EOF(MyFile)
Line Input #MyFile, TempLine
MyString = MyString + TempLine + Chr(13) + Chr(10)
Loop

response.write MyString
Close #MyFile
%>

Cheers for your help,
--inqbus--
 
You might also want to do
Response.Write Server.HTMLEncode(Mystring)
so that certain characters like &quot;<>&&quot; etc will not cause HTML errors on the other side.

Those CRLFs &quot;might&quot; be a problem.
if so then
Mystring = Replace(Mystring,Chr(13) & Chr(10),&quot;<BR>&quot;)

Response.Write Server.HTMLEncode(Mystring)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top