Read a text file and write sun Aug 2 06:34:07 1998
(Note: textstream write Method
Write (string)
Writeline (string)
Writeblanklines (lines)
)
This is 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" 'the default relative path is C: winnt
Set FS = Createobject ("scripting. FileSystemObject ")
Set F = FS. GetFile (filename)
Set readf = f. openastextstream (forreading, tristatefalse)
'The first parameter is optional. The input/output mode is one of the following three constants:
'Forreading = 1 read-only, forwriting = 2 read/write or forappending = 3 append
'The second parameter is also optional. One of the three tristate values,
'Indicates the format in which the file is opened. If this parameter is ignored, the file uses ASCII
'Format. Tristateusedefault =-2 open a file in the system default format,
'Tristatetrue =-1 open a file in unicode format or tristatefalse = 0
'Open the file in ASCII format.
'You can also use the opentextfile method to open a file.
S = readf. Readline
Do While readf. atendofline <> true
S = readf. Readline
Response. Write S & "" 'read and write files row by row
Loop
Readf. Close
%>
</Body>
</Html>
In this way, the text file can be read and displayed.