这就是我目前所拥有的...
Dim Test As String = "C:test.txt"
Dim User As String
Console.WriteLine("What user password would you like?")
User = Console.ReadLine().ToLower
Dim objReader As New System.IO.StreamReader(Test)
While Not objReader.EndOfStream
If User.Contains("Admin1") Then
Console.WriteLine(objReader.ReadLine())
End If
End While
objReader.Close()
我不确定是否需要在" (objReader.ReadLine() "的括号中放入某些内容,如果有人能提供帮助,那就太棒了,谢谢。
这是你想要的...
Using sr As New StreamReader("C:test.txt")
Dim Line As String = sr.ReadLine()
While Line IsNot Nothing
If Line.Contains("Admin1") Then
Console.WriteLine(Line)
End If
Line = sr.ReadLine()
End While
End Using
"使用"块可确保自动关闭和处置 StreamReader 对象,而无需担心它。