是否可以在循環內移動到下一行或臨時讀取下一行?我沒有找到任何有用的數據說明我會如何做到這一點,我的猜測是以某種方式找到您當前所在行的行號(索引),然後從您所在的位置讀取+1。移動到StreamReader中的下一行
Using TestFile As New IO.StreamReader(My.Settings.cfgPath & "tempRPT.txt", System.Text.Encoding.Default, False, 4096)
Do Until TestFile.EndOfStream
ScriptLine = TestFile.ReadLine
ScriptLine = LCase(ScriptLine)
If InStr(ScriptLine, "update: [b") Then
Dim m As Match = Regex.Match(ScriptLine, "\(([^)]*)\)")
builder.AppendLine(m.Value)
'This is where it would move to next line temporarily to read from it
If InStr(ScriptLine, "hive: write:") > 0 Or InStr(ScriptLine, "update: [b") > 0 Then 'And InStr(ScriptLine, "setmarkerposlocal.sqf") < 1 Then
builder.AppendLine(ScriptLine)
End If
End If
Loop
End Using
你可以用'System.IO.File.ReadAllLines()'在內存中讀取整個文件。 – ja72 2012-07-31 14:53:47