Someone plaese help me. I've tried every method in books and tutorials to read txt files into a textbox in vb.net and I KEEP getting an error saying "Could not find file "xxx.txt". This seems like a very simple peice of code. I've put the file in different directories and tried putting it in the "bin" folder where the application is located. No luck. I've never been able to get vb to find a file anywhere..Can anyone suggest any reason why the following codes dont work for me in my Click event?
Dim Rt As New System.IO.StreamReader("C:\test.txt")
Textbox1.Text = Rt.ReadToEnd
Rt.Close()
Then I tried this with the file in the \bin folder.
(Imported System.IO)
Dim TestFile As StreamReader
Dim Line As StreamWriter
TestFile = File.Open(Directory.GetCurrentDirectory() & "\test.txt")
Line = TestFile.ReadLine()
Dim Rt As New System.IO.StreamReader("C:\test.txt")
Textbox1.Text = Rt.ReadToEnd
Rt.Close()
Then I tried this with the file in the \bin folder.
(Imported System.IO)
Dim TestFile As StreamReader
Dim Line As StreamWriter
TestFile = File.Open(Directory.GetCurrentDirectory() & "\test.txt")
Line = TestFile.ReadLine()