[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
ASPFAQ_ReadTextFile
Back to ASP FAQ Main Page.
How to read and display a textfile
This example will show you how to read and display a textfile in ASP.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
ASPFAQ_ReadTextFile
Back to ASP FAQ Main Page.
How to read and display a textfile
This example will show you how to read and display a textfile in ASP.
<%
'Read a textfile example
'(c) 2001 Programmers Heaven
'http://www.programmersheaven.com
const ForReading=1 'Open the file for reading only
const TristateFalse=0 'Open the file as ASCII
dim fso,fil,Content,filename
'Create a FileSystemObject
set fso = Server.CreateObject("Scripting.FileSystemObject")
'Set the name of the file to read
filename="c:\testfile.txt"
'Open the textfile for reading
set fil = fso.OpenTextFile(filename,ForReading,false,TristateFalse)
'read the first line of the textfile
Content=fil.readall
response.write "<b>This is the content of the textfile:</b><br><pre>"
response.write Content
'Close the file
fil.close
'Release the objects
set fso=nothing
set fil=nothing
%>
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
