I'm trying to save my textbox1 content into a text file to my computer.
What I want to do is to create a save directory and when it's set up, I will save the content of textbox1
to that txt file.
Not just once, I want to append the content of the TextBox to the same file after.
Button2
: Trying to browse and create a txt file.
Button4
(1st click): This button will save the content of textbox1
to the txt file created.
Button4
(2nd click)": this will add the current content of textbox1
to the same txt file.
But I want to be able to change the directory whenever I want.
I also want to choose path outside the code or outside the textbox.
Meaning, I want a button that will let me choose a folder where I want to create a text file.
The 2nd button will let me save the textbox1
content to the created text file.
Here's some of my code but I don't know if I'm doing it correctly because it's now doing what I want. Please help.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim isave As New SaveFileDialog
isave.Filter = "txt files (*.txt) |*.txt"
isave.FilterIndex = 2
isave.RestoreDirectory = False
If isave.ShowDialog() = DialogResult.OK Then
IO.File.WriteAllText(isave.FileName, TextBox1.Text)
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim theText As String
theText = TextBox1.Text
IO.File.AppendAllText("isave", Environment.NewLine & theText)
End Sub