Share via


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."
    My.Computer.FileSystem.WriteAllText(
      "C://testfile.txt", inputString, True)
    

Robust Programming

The following conditions may cause an exception:

See Also

Reference

WriteAllText

FileSystem

Other Resources

Writing to Files in Visual Basic