OpenTextFileWriter

Opens a StreamWriter object to write to the specified file.


Syntax

FileSystem.OpenTextFileWriter(File, Append)

FileSystem.OpenTextFileWriter(File, Append, Encoding)


Parameters


File

String, input



File to be written to.


Append

Boolean, input



True to append to the contents in the file, False to overwrite the contents in the file. Default is False.


Encoding

Encoding, input



The encoding to be used in writing to the file. Default is ASCII.


Remarks


Encoding



ASCII

Gets an encoding for the ASCII (7-bit) character set.


Unicode

Gets an encoding for the UTF-16 format using the little endian byte order.


UTF32

Gets an encoding for the UTF-32 format using the little endian byte order.


UTF7

Gets an encoding for the UTF-7 format.


UTF8

Gets an encoding for the UTF-8 format.



StreamWriter Methods


Close()

Closes the current StreamWriter object and the underlying stream.


Flush()

Clears all buffers for the current writer and causes any buffered data to be written to the underlying stream.


Write(Var)

Writes the text representation of the variable to the text string or stream.


WriteLIne(Var)

Writes the text representation of the variable followed by a line terminator to the text string or stream.


Examples


This example opens a StreamWriter object with the OpenTextFileWriter method and uses it to write a string to a text file with the WriteLine method of the StreamWriter class:


Sub Main()

file = FileSystem.OpenTextFileWriter( "C:\Users\Public\My Directory\test.txt", True)

file.WriteLine "Here is my string."

file.Close

End Sub