Ok so I have a program that can save user's input into a text file and load it back, but whenever I try to open the file and exit without selecting the file I get an error.(if i select the file and open it i don't get any errors).
this is the code that handles text file loading
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
OpenFileDialog1.InitialDirectory = "C:\"
OpenFileDialog1.Filter = "Text Files ONLY (*.txt) | *.txt"
OpenFileDialog1.ShowDialog()
Dim loader As New IO.StreamReader(OpenFileDialog1.FileName)
TextBox1.Text = loader.ReadLine
TextBox2.Text = loader.ReadLine
TextBox3.Text = loader.ReadLine
TextBox4.Text = loader.ReadLine
TextBox5.Text = loader.ReadLine
TextBox6.Text = loader.ReadLine
TextBox7.Text = loader.ReadLine
TextBox8.Text = loader.ReadLine
TextBox9.Text = loader.ReadLine
TextBox10.Text = loader.ReadLine
TextBox11.Text = loader.ReadLine
TextBox12.Text = loader.ReadLine
TextBox13.Text = loader.ReadLine
TextBox14.Text = loader.ReadLine
TextBox16.Text = loader.ReadLine
TextBox57.Text = loader.ReadLine
loader.Close()
End Sub
the error is :"FileNotFoundException was unhandled. Could not find file at xxx"
also I would like to know how to make it so that the initial file name for file saving is today's date.
I do not get any errors when I try to save the file, please help :(