FileSystemProxy.OpenTextFileWriter Method (String, Boolean)
Opens a StreamWriter object to write to the specified file.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
- Type: System.String
File to be written to.
- Type: System.Boolean
True to append to the contents of the file; False to overwrite the contents of the file. Default is False.
The OpenTextFileWriter method opens and initializes a stream for a file and then returns the StreamWriter object for that stream. You can write to the steam as many times as necessary and then close it when you are finished.
If you are writing only a few strings to a file, it might be simpler to use the WriteAllText method.
The following table lists an example of a task involving the My.Computer.FileSystem.OpenTextFileWriter method.
Write text to a file with a StreamWriter
This example opens a StreamWriter with the My.Computer.FileSystem.OpenTextFileWriter method and uses it to write a string to a text file with the WriteLine method of the StreamWriter class.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.