I'm reading a text file using a stream read and my code goes like this
FileStream file = new FileStream("c:/data/theData.txt", FileMode.Open, FileAccess.Read);
StreamReader streamReader = new StreamReader(file);
// read the content of the first line of the data text file
String line = streamReader.ReadLine();
while (line != "")
{
// check the value of the line
if (line.Equals("<data>"))
{
..... // code here
}
// read the next line of the text file
line = streamReader.ReadLine();
}
the problem is that whenever i run my program, this error occurs on runtime:
"Object reference not set to an instance of an object" and it's pointing at the
"if(line.Equals("<data>"))"... what's wrong? i used to do this in java and it works..