gregw74
09-01-2006, 11:04 AM
As a rookie in the world of ASP I was looking for a method to store the contents of text file within a variable. I am so far able to read a text file and output the results. Going a step further I also wanted to replace a particular string within those same results using the "Replace" function. This much works as well, but only when it is written to the screen. My question, how can I store the final result within a variable so that I can reference it later.
The working code I am using now, is as follows:
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("junk.txt"), 1)
do while f.AtEndOfStream = false
response.write(Replace(f.ReadLine, "________", "12345"))
Response.Write("<br>")
loop
f.Close
Set f=Nothing
Set fs=Nothing
%>
The working code I am using now, is as follows:
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("junk.txt"), 1)
do while f.AtEndOfStream = false
response.write(Replace(f.ReadLine, "________", "12345"))
Response.Write("<br>")
loop
f.Close
Set f=Nothing
Set fs=Nothing
%>