Name

WriteLine (TextStream Object) — tsObj .WriteLine([ strWriteString ])

Synopsis

Writes a string's value into an open file at the location of the pointer within the file. This method also writes a newline character to the end of the added string. Otherwise, it is exactly the same as the Write method.

strWriteString

A string that represents the text you wish to write to the open text file

Example

<%

' 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 a string variable that 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 plus a newline character to the
' end of the opened file.
tsObject.WriteLine strEnding
. . . [additional code]

%>

Notes

After calling the WriteLine method, the file pointer will point to the character located immediately after the newline character added to the file.

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.