![]() |
![]() |
|||||||||||||||||||||||
|
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.function TextStreamTest( )
{
var ForReading = 1, ForWriting = 2, ForAppending = 3;
var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
var fs, f, ts, s;
fs = new ActiveXObject("Scripting.FileSystemObject");
fs.CreateTextFile( "test1.txt" ); // Create a file
f = fs.GetFile("test1.txt");
ts = f.OpenAsTextStream(ForWriting, TristateUseDefault);
ts.Write( "Hello World" );
ts.Close( );
ts = f.OpenAsTextStream(ForReading, TristateUseDefault);
s = ts.ReadLine( );
ts.Close( );
Response.Write(s);
}
Copyright © 2000 Chili!Soft