in reply to Re^2: Connecting Perl's STDIN and STDOUT to .Net StreamReader
in thread Connecting Perl's STDIN and STDOUT to .Net StreamReader
I think Corion called it right. From the docs (my emphasis):
The current position of the StreamReader object is not changed by Peek. The returned value is -1 if no more characters are currently available
That suggests .Peek will return -1 when there is nothing currently available. Not when nothing more will ever become available (in a microsecond from now).
Your fix is probabaly to use the "standard c# idiom":
using (StreamReader sr = ... ) { string line; // Read and display lines from the file until the end +of // the file is reached. while ((line = sr.ReadLine()) != null) { ... } } }
|
|---|