New StreamWriter Constructor

Constructor for creating a StreamWriter Object.  Also opens a file or device for writing.

New StreamWriter ( path )
-or-
New StreamWriter( path, append )

Prerequisites

None

Parameters

path

A String that contains the path for the file or device to open. Serial ports are devices named "/dev/com1", "/dev/com2", etc.   Remote serial ports are named "/dev/comrxy" where "x" is the number of the remote device and "y" is the number of the serial port on the remote device.  Temporary files may be placed on device "/ROMDISK" and permanent files may be placed on "/flash".

append

A Boolean value that determines whether or not new data should be appended to the end of an existing file. If append is False, a new file is always created, overwriting any existing file with the same name.

Remarks

This method opens a file or device and associates it with a new StreamWriter Object.

By default, AutoFlush is enabled for serial ports and the /NVRAM device but not for files on other devices.

If any error occurs, this method throws an Exception.

Examples

Dim com1 As New StreamWriter("/dev/com1")          ' Open serial port #1
Dim tfile As New StreamWriter("/ROMDISK/test.tmp") ' Open temporary file
Dim pfile As New StreamWriter("/flash/save.txt") ' Open permanent file

See Also

File and Serial I/O | New StreamReader | streamwriter_object.AutoFlush