如何使用objreader读取特定行
问题描述:
我正在使用objreader.readline来读取我的config.txt文件以获取信息,但我似乎无法让它读取整行。
我的代码:
I''m using objreader.readline to read my config.txt file to pull information, however I can''t seem to get it to read the whole line.
My code:
Dim FILE_NAME As String = "C:\Config.txt"
Dim objReader As New System.IO.StreamReader(FILE_NAME)
settings.TextBox3.Text = objReader.ReadLine(5)
objReader.Close()
当我使用objreader.readline时( 1)它只读取第1行的字符。我希望它读取整行。
例如:
objreader.readline(3)
1.测试
2.测试
3.我希望所有这些都显示在我的文本框中。
4.测试
5.测试
我使用正确的字符串吗?
When I use objreader.readline(1) It will read only the character on line 1. I want it to read the whole line.
Example:
objreader.readline(3)
1. Test
2. Test
3. I want all of this to show in my text box.
4. Test
5. Test
Am I using the right string?
答
它实际上读了整行:
http://msdn.microsoft.com/en-us/library/system.io.streamreader.readline.aspx [ ^ ]。
你实际上读了整行,而不是通过索引提取一个字符。难怪你得到一个角色。删除此5。 (并且不要硬编码任何东西,例如索引。)-SA
It actually does read the whole line:
http://msdn.microsoft.com/en-us/library/system.io.streamreader.readline.aspx[^].
You actually read the whole line and than extract just one character by its index. No wonder you get one character. Remove this "5". (And don''t hard-code anything, for example, indices.)—SA