Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

WriteLine Method (FileSystemObject)

Writes a specified string and newline character to a TextStream file.


                      object
                      .WriteLine([string])

object

Required. Always the name of a TextStream object.

string

Optional. The text you want to write to the file. If omitted, a newline character is written to the file.

The following example illustrates use of the WriteLine method:

var fso, f;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.CreateTextFile("c:\\testfile.txt", true);
f.WriteLine("This is a test.");
f.Close();

Function WriteLineToFile
   Const ForReading = 1, ForWriting = 2
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
   f.WriteLine "Hello world!" 
   f.WriteLine "VBScript is fun!"
   Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
   WriteLineToFile = f.ReadAll
End Function

Applies To:

Community Additions

Show:
© 2015 Microsoft