Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The WriteAllText method can be used to append to a text file by specifying that the append
parameter is set to True
.
To append to a text file
Use the
WriteAllText
method, specifying the target file and string to be appended and setting theappend
parameter toTrue
.This example writes the string
"This is a test string."
to the file namedTestfile.txt
.Dim inputString As String = "This is a test string." My.Computer.FileSystem.WriteAllText( "C://testfile.txt", inputString, True)
Robust Programming
The following conditions may cause an exception:
The path is not valid for one of the following reasons: it is a zero-length string, it contains only white space, it contains invalid characters, or it is a device path (starts with \\.\) (ArgumentException).
The path is not valid because it is
Nothing
(ArgumentNullException).File
points to a path that does not exist (FileNotFoundException or DirectoryNotFoundException).The file is in use by another process, or an I/O error occurs (IOException).
The path exceeds the system-defined maximum length (PathTooLongException).
A file or directory name in the path contains a colon (:) or is in an invalid format (NotSupportedException).
The user lacks necessary permissions to view the path (SecurityException).