Creates a specified file name and returns a TextStream object that can be used to read from or write to the file.
object.CreateTextFile(filename[, overwrite[, unicode]])
The following code illustrates how to use the CreateTextFile method to create and open a text file.
[JScript] var fso = new ActiveXObject("Scripting.FileSystemObject"); var a = fso.CreateTextFile(
"c:\\testfile.txt",
true)
; a.WriteLine("This is a test."); a.Close(); [VBScript] Sub CreateAfile Dim fso, MyFile Set fso = CreateObject("Scripting.FileSystemObject") Set MyFile = fso.CreateTextFile(
"c:\testfile.txt",
True)
MyFile.WriteLine("This is a test.") MyFile.Close End Sub
If the overwrite argument is false, or is not provided, for a filename that already exists, an error occurs.
CreateFolder Method | OpenAsTextStream Method | OpenTextFile Method
Applies To: FileSystemObject Object | Folder Object