VB.Net从文件中读取文本而忽略第一行

时间:2015-04-27 21:42:18

标签: vb.net

我有数据:

  

“#DAYS”
  “直到年龄为704的日子”   “你将在766天内死去”

我想阅读该文字,但我想跳过开始#

的文字

1 个答案:

答案 0 :(得分:0)

跳过第一行

Dim readFirst as Boolean
For Each line As String In IO.File.ReadAllLines("Path to the file")
    If readFirst Then
        'Process lines except the first
    End If
    readFirst = True
Next

如果您想跳过所有以"#"

开头的行
For Each line As String In IO.File.ReadAllLines("Path to the file")
    If Not line.StartsWith("#") Then
        'Process lines that don't start with "#"
    End If
Next