vb.nettextboxsavenotepadsave-as

How to save textbox text to notepad and save again a textbox text to add it into the same note pad?


I want to save my textbox1.text in a notepad of my computer. And after saving that, I will save the next textbox1.text again. But I want it to be added to the same notepad. Anyone can help me on the code? Using VB net.

I have a one form with controls and all entries will be displayed on one textbox. I want to save that textbox but I don't know how.


Solution

  • You could use the File.AppendAllText method to save the text to a file:

    Public Sub SaveTextToFile(FilePath As String, Text As String)
        System.IO.File.AppendAllText(FilePath, Text)
    End Sub
    

    Here is an example of using the method:

    SaveTextToFile("C:\New.txt", textBox1.Text)