首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

怎么读写文本文件指定行的内容

2012-03-05 
如何读写文本文件指定行的内容如何读写文本文件指定行的内容[解决办法]Imports SystemImports System.IOCl

如何读写文本文件指定行的内容
如何读写文本文件指定行的内容

[解决办法]
Imports System
Imports System.IO

Class Test
Public Shared Sub Main()
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader( "TestFile.txt ")
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Console.WriteLine(Line)
Loop Until line Is Nothing
sr.Close()
Catch E As Exception
' Let the user know what went wrong.
Console.WriteLine( "The file could not be read: ")
Console.WriteLine(E.Message)
End Try
End Sub
End Class

热点排行