如何阅读文本文件 [英] How to Read Text file

查看:94
本文介绍了如何阅读文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,
我正在VS2010中的VB.NET中开发一个应用程序.现在,我需要阅读外部文本文件.我应该如何读取文本文件并在一个字符串中获取文本文件的第一行,而在另一个字符串中获取文本文件的第二行........

请帮助我.....
感谢ADV. . . .

Hai All,
I am developing one application in VB.NET in VS2010. Now i need to read the external text file. How i should read text file and get the First line of text file in one string and second line of text file in another string........

Please help me.....
Thanks in ADV. . . .

推荐答案

这是一个示例:

here is an example:

' Read From a Text File
Dim fileLoc As String = "filepath"
If File.Exists(fileLoc) Then
Using tr As TextReader = New StreamReader(fileLoc)
      MessageBox.Show(tr.ReadLine())
End Using
End If



另请参阅本文以了解其他文件操作和示例代码

http://www.dotnetcurry.com/ShowArticle.aspx?ID=144 [ ^ ]



also see this article for other file operations & sample code

http://www.dotnetcurry.com/ShowArticle.aspx?ID=144[^]


这篇关于如何阅读文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆