在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, useSystem.IO.StreamReader
with the methodsReadLine
orReadAllLines
:
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") '<-- where to read from
'Dim tempstring As String
' Do
s = Reader.ReadLine()</pre>
此代码对您有帮助
如果您有任何相关信息,请回复我........
this code is helpful for you
if you have any about this please reply me........