Use ASP to read out text files and display
Read a text file and write the Sun Aug 2 06:34:07 1998
(Note: TextStream about written method
Write (STRING)
WriteLine (STRING)
WriteBlankLines (LINES)
)
It's a complete program.
〈html〉
〈head〉
〈http-equiv= "Content-type" content= "text/html; charset=gb2312 "
〈title〉〈/title〉
〈/head〉
〈body〉
% LANGUAGE = VBScript%
%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const Tristateusedefault =-2, TristateTrue =-1, tristatefalse = 0
Dim filename
filename = "test.txt" ' Default relative path is C:winnt
Set fs = CreateObject ("Scripting.FileSystemObject")
Set f = fs. GetFile (filename)
Set READF = F.openastextstream (forreading,tristatefalse)
' The first argument is optional. Input/output mode, which is one of the following three constants:
' Forreading=1 read-only, forwriting=2 writable or forappending=3 append
' The second parameter is optional. One of three tristate values,
' indicates in what format the file is opened. Ignoring this parameter, the file is in ASCII
' Format open. Tristateusedefault=-2 opens the file in the system default format,
' Tristatetrue=-1 open file or tristatefalse=0 in Unicode format
' Open the file in ASCII format.
' You can also open files using the OpenTextFile method
s = readf. ReadLine
Do While READF. AtEndOfLine <> True
s = readf. ReadLine
Response.Write S & "" read the file line by row and write
Loop
Readf.close
% >
</body>
This allows you to read and display the text file.