![]() |
![]() |
|||||||||||||||||||||||
|
Constant | Value | Description |
ForReading |
1 |
Open a file for reading only. You can't write to this file. |
ForWriting |
2 |
Open a file for writing. If a file with the same name exists, its previous contents are overwritten. |
ForAppending |
8 |
Open a file and write to the end of the file. |
Constant | Value | Description |
TristateUseDefault |
-2 |
Opens the file using the system default. |
TristateTrue |
-1 |
Opens the file as Unicode. |
TristateFalse |
0 |
Opens the file as ASCII. |
Remarks
The OpenAsTextStream method provides the same functionality as the OpenTextFile method of the FileSystemObject. In addition, the OpenAsTextStream method can be used to write to a file.Sub TextStreamTest
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateTextFile "test1.txt"
'Create a file
Set f = fs.GetFile("test1.txt")
Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)
ts.Write "Hello World"
ts.Close
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
s = ts.ReadLine
Response.Write s
ts.Close
End Sub
Copyright © 2000 Chili!Soft