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.

Nevermind. Found it very simple

Try
            Using Filereader As New IO.StreamReader(SettingsFilename)


                Name = Int(Filereader.ReadLine.Contains("Name="))
            End Using
        Catch E As Exception
            ' Let the user know what went wrong.
            MsgBox(E.Message)
        End Try
        Username = Name

well you never start to read the lines
try this code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim Filereader As New IO.StreamReader("Test.txt")
            Dim CurrentLine As String = Filereader.ReadLine

            While Not Filereader.EndOfStream
                CurrentLine = Filereader.ReadLine
                If CurrentLine.Contains("Name=") Then
                    username = CurrentLine
                    Exit While
                End If
            End While
        Catch ex As Exception
            ' Let the user know what went wrong.
            MsgBox(ex.Message)
        End Try
    End Sub

^^ So that was the error, I found the solution. Thanks anyway

Private Sub Form1_Load()

            Dim FileReader As New IO.StreamReader("Test.txt")
            Dim FileString As String = ""

            While Not Filereader.EndOfStream
                Filestring = FileReader.ReadLine()
                If (Filestring.StartsWith("Name") = True) Then
                    Name = (FileString.Substring(6, 5))
                    Exit While
                End If
            End While

    End Sub
This question has already been answered. Start a new discussion instead.