Using VB net,
I'm trying to save my textbox1 content into a txtfile to my computer.
What I want to do is to create a save directory and when it's set up, I will save the textbox1 content to that txt file. Not just once but I want to save the 2nd content of textbox1 to the same txt file like append text.
Button 2: Trying to browse and create a txt file.
Button 4(1st click): This button will save the content of textbox1 to the txt file created.
Button 4(2nd click)" This will add another 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 txt file.
The 2nd button will let me save the textbox1 content to the created txt 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.
Code:` ``` 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 ``` `




Reply With Quote
