Ads |
|
 |
|
Products |
|
 |
|
|
|
 |
 |
 |
|
|
Reading a file
In this example we open a file which is in this case called sampletext.txt . This file contains several lines which we wish to display , so we loop the lines of text one at a time and display them until there are none left to display.
|
<%
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
%> |
|
|
|
|
|
|
 |
 |
 |
Products |
|
 |
|
|
Comparison |
|
 |
|
|
Ads |
|
 |
|
|
|