### Handle TextReader & Writer Exceptions

The principle of using Try .. Catch exceptions.
...
Try
Dim tr As TextReader
...
Catch
Log("Read Text File: Error " & LastException.Message)
If tr.IsInitialized Then tr.Close
End Try
...
Try
Dim tw As TextWriter
...
Catch
Log("Write Text File: Error " & LastException.Message)
If tw.IsInitialized Then tw.Close
End Try
...
Example
Dim myTextReader As TextReader
Try
myTextReader.Initialize(File.OpenInput("D:\data\", "big.csv") )
Dim LineCounter As Int = 0
Dim line As String = myTextReader.ReadLine
Do While line <> Null
LineCounter = LineCounter + 1
line = myTextReader.ReadLine
If LineCounter Mod 10000 = 0 Then
Log("Line: " & NumberFormat(LineCounter, 0, 0))
End If
Loop
myTextReader.Close
Catch
Log("Error --> " & LastException.Message)
If myTextReader.IsInitialized Then
myTextReader.Close
End If
End Try

Changed: , Category: TextReader and TextWriter, File: T6C263M1951.htm, ID: 1951