How to: Write Text to Files with a StreamWriter in Visual Basic
This example opens aobject with the My.Computer.FileSystem.OpenTextFileWriter method and uses it to write a string to a text file with the method of the StreamWriter class.
The following conditions may cause an exception:
The file exists and is read-only ().
The disk is full (IOException).
The pathname is too long ().
This example creates a new file, if the file does not already exist. If an application needs to create a file, that application needs Create access for the folder. If the file already exists, the application needs only Write access, a lesser privilege. Where possible, it is more secure to create the file during deployment, and only grant Read access to a single file, rather than Create access for a folder.