Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

JScript FileSystemObject Object CreateTextFile Method

Creates a specified file name and returns a TextStream object that can be used to read from or write to the file.

Syntax: JScript FileSystemObject Object CreateTextFile Method

object.CreateTextFile(filename[, overwrite[, unicode]])

Arguments: JScript FileSystemObject Object CreateTextFile Method

object

The name of a FileSystemObject object. Required.

filename

A String expression that identifies the file to create. Required.

overwrite

A Boolean value that indicates whether you can overwrite an existing file. The value is true if the file can be overwritten, false if it can't be overwritten. If omitted, existing files are not overwritten. Optional.

unicode

A Boolean value that indicates whether the file is created as a Unicode or ASCII file. The value is true if the file is created as a Unicode file, false if it's created as an ASCII file. If omitted, an ASCII file is assumed. Optional.

Remarks: JScript FileSystemObject Object CreateTextFile Method

The following code illustrates how to use the CreateTextFile method to create and open a text file:

var fs = new ActiveXObject("Scripting.FileSystemObject");

var a = fs.CreateTextFile("c:\\testfile.txt", true);

a.WriteLine("This is a test.");

a.Close();

If the overwrite argument is False, or is not provided, for a filename that already exists, an error occurs.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.