description
Open the specified file and return one
TEXTSTREAM object, this object is used to read, write or add operations to files.
grammar
Object
.Openastextstream
Iomode, [
Format]]]]
)
The syntax of the OpenASTextStream method has the following parts:
Some describe Object must be selected. The name of the FILE object. Iomode is optional. Input / output mode is one of the following three constants: Forreading, Forwriting or FORAPPENDING. Format is optional. One of the three Tristate values indicates to the format to open the file. Ignore this parameter, the file is opened in ASCII format.
Set
The Iomode parameter can be one of the following settings:
The constant value describes that forwarding1 opens a file in read-only mode. This file cannot be written. FORWRITING2 opens files in readable write mode. If the files already have the same name already, override the old file. FORAPPENDING8 Opens the file and write it at the end of the file.
The Format parameter can be one of the following settings:
The constant value description TristateUsesedefault-2 opens the file in the default format of the system. TristateTrue-1 Opens file in Unicode format. Tristatefalse 0 Opens files in ASCII format.
Description
OpenastextStream method provides
FileSystemObject object
The OpenTextFile method is the same function. In addition, use
The OpenASTextStream method can write to the file.
The following code example shows how to use the OpenASTextStream method:
Function TextStreamtest
Const forreading = 1, forWriting = 2, FORAPPPpending = 8
Const tristateusedefault = -2, tristatetrue = -1, tristatefalse = 0
DIM FSO, F, TS
SET FSO = CreateObject ("scripting.filesystemObject")
Fso.createtextFile "Test1.txt" creates a file.
Set f = fso.getfile ("test1.txt")
SET TS = f.OpenastextStream (ForWriting, TristateuseDefault)
Ts.write "Hey, hello!"
Ts.close
Set Ts = f.OpenastextStream (Forreading, TristateuseDefault)
TextStreamtest = TS.Readline
Ts.close
END FUNCTION