[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.

<%
'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
%>


last edited (December 9, 2002) by KDivad Leahcim, Number of views: 2221, Current Rev: 3 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.