TextStream.Write()

JScript2.0+Syntax

							textstream.Write(string)

Description

The Write() method of an instance of the TextStream object is used to write a string to the text file.

Example

Listing 9.134 opens a text file and writes a string to it. This file can be executed with the Windows Scripting Host (wscript.exe or cscript.exe).

Listing 9.134 Using the Write() Method
// Create a FileSystemObject object
var myFileSysObj = new ActiveXObject("Scripting.FileSystemObject")

// Create a TextStream object
var myTextStream = myFileSysObj.OpenTextFile("c:\\temp\\test.txt", 2, true)

// Write a string to the file
myTextStream.Write("Hello, World!");

// Close the stream to the file
myTextStream.Close();
						

Get Pure JavaScript 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.