用streamreader读取,好像释放文件很慢,要30秒才能释放,文件很小才15行,不知道问题出在哪里。
SST_X 2019-07-02 01:46:43 Try
Dim sr As StreamReader = New StreamReader(taskStr1)
While foundDefectInTestFile = 1
line = sr.ReadLine()
If line Is Nothing Then
foundDefectInTestFile = 0
Exit While
Else
My.Computer.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & "\logfile" & "\T2.txt", taskStr1 & vbCrLf, True, System.Text.Encoding.GetEncoding("GB2312"))
If InStr(UCase(line), "PROGRAM VALUE") > 0 Then
prgStr1 = Mid(line, line.IndexOf(Chr(34)) + 2, line.LastIndexOf(Chr(34)) - line.IndexOf(Chr(34)) - 1)
prgStr2 = prgStr1
My.Computer.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & "\logfile" & "\TEST2.txt", prgStr1 & " " & prgStr & vbCrLf, True, System.Text.Encoding.GetEncoding("GB2312"))
If prgStr1 = prgStr Then
foundDefectInTestFile = 0
'Exit For
Else
prgStr = prgStr2
End If
End If
End If
End While
sr.Close()
sr = Nothing
Catch ex As Exception
My.Computer.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & "\logfile" & "\exception.txt", ex.ToString & vbCrLf, True, System.Text.Encoding.GetEncoding("GB2312"))
' Return
End Try