我有一个文件,其中包含逐行编写的测试日期和结果。我想编辑文件,以便删除任何没有今天日期的行,然后保存文件(删除不需要的行)。帮助将不胜感激。
Dim rawlines() As String
Dim outputlines As New List(Of String)
rawlines = File.ReadAllLines("C:usersuser10rslts.csv")
For Each line As String In rawlines
If line.Contains(today()) = True Then
outputlines.Add(line)
End If
Next
读取行数:
Dim rawlines() As String
Dim outputlines As New List(Of String)
rawlines = File.ReadAllLines("C:usersuser10rslts.csv")
For Each line As String In rawlines
If line.Contains(today()) = True Then
outputlines.Add(line)
End If
Next
将行写入新文件:
Dim MyFile As StreamWriter
File.Create("c:testTheResults.csv").Close()
MyFile = File.AppendText("c:testTheResults.csv")
For Each Line As String In outputlines
MyFile.WriteLine(Line)
Next
MyFile.Close()