StreamReader.readline() problem
-
hi, i have a program that receiving inforamtion from a port (SerialPort object). i am reading the port's information(Stream) from another object by StreamReader like this:
SerialPort port=new SerialPort(.....);
port.NewLine= "\r";
StreamReader sr=new StreamReader(port.BaseStream);while reading the the stream to the end:
while (!sr.endOfFile)
{
line= sr.readLine();
}this Method stucks on the last line on the stream.it reads all the Stream except the last line. But after adding information (Strings) to the stream (from the port).. it continues reading the last line with the new information... do you know how to solve it? thank you.. P.S Maybe..is it something with the sr.NewLine argument?
-
hi, i have a program that receiving inforamtion from a port (SerialPort object). i am reading the port's information(Stream) from another object by StreamReader like this:
SerialPort port=new SerialPort(.....);
port.NewLine= "\r";
StreamReader sr=new StreamReader(port.BaseStream);while reading the the stream to the end:
while (!sr.endOfFile)
{
line= sr.readLine();
}this Method stucks on the last line on the stream.it reads all the Stream except the last line. But after adding information (Strings) to the stream (from the port).. it continues reading the last line with the new information... do you know how to solve it? thank you.. P.S Maybe..is it something with the sr.NewLine argument?
-
it stucks on readLine. i mean, the processor arrives to this line (line= sr.readline()) and just stop. even if i add another line to while:
while(!sr.endOffile)
{
line= sr.readline(); <------------it stops here------
messageBox.show("Just string"); the processor do not arrive to this line}
the processor stops working even if the Stream is not endOfFile. Why?! P.S i changed !sr.endofFile to line!=null it is still not working...
-
hi, i have a program that receiving inforamtion from a port (SerialPort object). i am reading the port's information(Stream) from another object by StreamReader like this:
SerialPort port=new SerialPort(.....);
port.NewLine= "\r";
StreamReader sr=new StreamReader(port.BaseStream);while reading the the stream to the end:
while (!sr.endOfFile)
{
line= sr.readLine();
}this Method stucks on the last line on the stream.it reads all the Stream except the last line. But after adding information (Strings) to the stream (from the port).. it continues reading the last line with the new information... do you know how to solve it? thank you.. P.S Maybe..is it something with the sr.NewLine argument?
ReadLine doesn't terminate until it encounters a NewLine; try a different method.