This is some sample code for reading a file with ASP.
Tutorial Details:
ASP File Manipulation
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 & " "
Loop
End If
objTextStream.Close
'good practice to setobject variables to nothing
Set objFSO = Nothing
Set objTextStream = Nothing
%>
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: ASP File Manipulation Open and Read a File with ASP Tutorial
View Tutorial: ASP File Manipulation Open and Read a File with ASP Tutorial
Related
Tutorials:
|