This documentation is archived and is not being maintained.

How to: Append to Text Files in Visual Basic

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 the append parameter to True.

    This example writes the string "This is a test string." to the file named Testfile.txt.

    Dim inputString As String = "This is a test string."
      "C://testfile.txt", inputString, True)

The following conditions may cause an exception: