在vb.net中读取txt文件 [英] Read txt file in vb.net

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

问题描述

Dim FileNumber As Integer = 1
        Dim FileName As String = "C:\Users\TestFile.txt"
        FileOpen(1, FileName, OpenMode.Input)
        While Not EOF(1)
            Console.WriteLine(InputString(1, 1))
        End While
        FileClose(1)





我不知道这段代码有什么问题,它无法读取我的文件任何人都可以提供帮助

我希望这段代码能够读取我的TestFile.txt



I dont know what's wrong with this code, its could not read my file anyone could help
I want this code to read my TestFile.txt

推荐答案

你甚至都没有尝试阅读任何东西。使用文本文件,使用 System.IO.StreamReader ,方法为 ReadLine ReadAllLines

http:// msdn。 microsoft.com/en-us/library/system.io.streamreader.aspx [ ^ ]。



你能解释一下:为什么你会忽略你之前的答案题?这个问题在技术上不是重新发布,但有点多余。



-SA
You are not even trying to read anything. With text files, use System.IO.StreamReader with the methods ReadLine or ReadAllLines:
http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx[^].

And could you explain: why would you ignore the answer to your previous question? This question is technically not quite a re-post, but somewhat redundant.

—SA


Dim Reader As System.IO.StreamReader
dim s as string
            Reader = New System.IO.StreamReader("C:\<pre lang="xml">Users\TestFile.txt&quot;) &#39;&lt;-- where to read from
            &#39;Dim tempstring As String
            &#39; Do
            s = Reader.ReadLine()</pre>





此代码对您有帮助



如果您有任何相关信息,请回复我........



this code is helpful for you

if you have any about this please reply me........


这篇关于在vb.net中读取txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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