vb.net怎么从文本文档中读取一行数据,将文本输出到控制台?
1个回答
展开全部
以下示例一次从文件中读取一行,然后将每行文本打印到控制台。
Sub ReadTextLinesFromFile()
Dim file As New System.IO.StreamReader("c:test.txt")
Dim oneLine As String
oneLine = file.ReadLine()
While (oneLine <> "")
Console.WriteLine(oneLine)
oneLine = file.ReadLine()
End While
file.Close()
End Sub
Sub ReadTextLinesFromFile()
Dim file As New System.IO.StreamReader("c:test.txt")
Dim oneLine As String
oneLine = file.ReadLine()
While (oneLine <> "")
Console.WriteLine(oneLine)
oneLine = file.ReadLine()
End While
file.Close()
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询