This example writes a string to a text file using the WriteLine method of the StreamWriter class.
Example
Dim file As New System. IO. StreamWriter ("c: est.txt ")
File. WriteLine ("Here is the first line .")
File. Close ()
Compiling the Code
This example requires:
A reference to System namespace. Robust Programming
The following conditions may cause an exception:
The file exists and is read-only (IOException Class). The disk is full (IOException Class). The pathname is too long (PathTooLongException Class). Security
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 (see Access Control ). 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.