'Check if the file has any broken records Dim reader As StreamReader = New StreamReader(fileDirectory) Dim fileLine As String Dim stopCheck As Boolean = False Do While reader.Peek() > -1 fileLine = reader.ReadLine() 'If the line is not start with eCW| then it is a broken record If Not fileLine.StartsWith("eCW|") Then stopCheck = True Exit Do End If Loop reader.Close() If stopCheck Then It will take a very long time to validate the rows when the text file has many records.
ex. File 1 has 500,000 completed records. It will looping through all the rows until it close the program.
File 2 has a broken records toward the end of text file. It will have to looping through all the rows before it find the broken record.
Is there a way to speed up this validation process?
StreamReadervariable to avoid problems (e.g., file getting locked); you can easily take care of that with theUsingstatement.