Share via


How to: Append to Text Files in Visual Basic

The My.Computer.FileSystem.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

My.Computer.FileSystem.WriteAllText Method

My.Computer.FileSystem Object

Other Resources

Writing to Files in Visual Basic