|
Read from a file
This shows how to read from a file . I have created
a sampletext.txt file . If you choose to put your text files
in a different location then remember and change the Server.MapPath
Here is the code for this example
<%
Const ForReading = 1
' our variables
Dim objFSO , objTextStream , strText , strFileName
'Path to our text file
strFileName = Server.MapPath("sampletext.txt")
'create an instance of the FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'open our text file
Set objTextStream = objFSO.OpenTextFile(strFileName , ForReading
, False)
If not objTextStream.AtEndOfStream Then
Do While not objTextStream.AtEndOfStream
'read in our text one line at a time and display it
strText = objTextStream.ReadLine
Response.Write strText & "<br>"
Loop
End If
objTextStream.Close
'good practice to setobject variables to nothing
Set objFSO = Nothing
Set objTextStream = Nothing
%>
|