July 2000
Intermediate to advanced
492 pages
14h 53m
English
Write (TextStream Object) —
tsObj
.Write(
strWriteString
)
Writes a specified string to an open text file at the current location of the file pointer.
strWriteString
A string that represents the text you wish to write to the open file
<%
' Dimension local variables.
Dim fsoObject ' FileSystemObject
Dim filObject ' File Object
Dim tsObject ' TextStream object
Dim strEnding
' Declare file access constants.
Const ForAppending = 8
Const TristateFalse = 0
' Initialize string variable. This string will be
' written to the end of the file opened next.
strEnding = "This is the end, my only friend, the end..."
' Instantiate the FileSystemObject variable.
Set fsoObject = Server.CreateObject( _
"Scripting.FileSystemObject")
' Using the GetFile method of fsoObject, initialize the
' File object.
Set filObject = fsoObject.GetFile("d:\docs\test.txt")
' Use the OpenAsTextStream method to open the file for
' appending and in Unicode format.
Set tsObject = filObject.OpenAsTextStream(ForAppending, TristateFalse)
' Write a short string to the end of the opened file.
tsObject.Write strEnding
. . . [additional code]
%>The Write method does not place any characters at the beginning or end of each written string. For this reason, if you use the Write method to add to a file, make sure that you include any desired characters (like spaces or newline characters) at the beginning or end of the strings you write to the file.
Read now
Unlock full access