I am trying to read a specific line from .txt file. The problem is the the whole application hangs. It does not display any error, just hangs
Imports System
Imports System.IO
Dim Username As String = ""
Private Sub Form1_Load()
Try
Dim Filereader As New IO.StreamReader("Test.txt")
Dim CurrentLine As String = ""
Do
If CurrentLine.Contains("Name=") Then
'Store whole line into variable
Username = CurrentLine
Exit Do
End IF
Loop Until CurrentLine Is Nothing
Catch E As Exception
' Let the user know what went wrong.
MsgBox(E.Message)
End Try
Textbox1.Text = Username
End Sub
The file path is fine because I can write on the filename(Test.txt). The problem is reading it.