I cant see why I get the following error, on the highlighted line in the code below, when I try to open a file that does not exist:
An unhandled exception of type System.NullReferenceException occurred in WebTrendsLogs.exe
Additional information: Object reference not set to an instance of an object.
[VB]
Dim fsInput As FileStream
Try
Open the file.
fsInput = New FileStream(sreadFile, FileMode.Open, FileAccess.Read)
Try
srInput = New StreamReader(fsInput)
Read File.
sFileLine = srInput.ReadLine()
While Not IsNothing(sFileLine)
Append to array.
sContents.Add(sFileLine)
Read File.
sFileLine = srInput.ReadLine()
End While
Catch eIO As Exception
MessageBox.Show("Couldnt read the file " & sFile, "Error Message", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
srInput.Close()
End Try
Catch eFile As Exception
MessageBox.Show("Couldnt open file " & sFile, "Error Message", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
fsInput.Close()
End Try
[/VB]
Any assistance will be greatfully received, Thanks
An unhandled exception of type System.NullReferenceException occurred in WebTrendsLogs.exe
Additional information: Object reference not set to an instance of an object.
[VB]
Dim fsInput As FileStream
Try
Open the file.
fsInput = New FileStream(sreadFile, FileMode.Open, FileAccess.Read)
Try
srInput = New StreamReader(fsInput)
Read File.
sFileLine = srInput.ReadLine()
While Not IsNothing(sFileLine)
Append to array.
sContents.Add(sFileLine)
Read File.
sFileLine = srInput.ReadLine()
End While
Catch eIO As Exception
MessageBox.Show("Couldnt read the file " & sFile, "Error Message", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
srInput.Close()
End Try
Catch eFile As Exception
MessageBox.Show("Couldnt open file " & sFile, "Error Message", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
fsInput.Close()
End Try
[/VB]
Any assistance will be greatfully received, Thanks