writeline

  • Thread starter Thread starter RobcPettit
  • Start date Start date
R

RobcPettit

Hi, Using Console.Writeline, as
while ((strLine = stream.ReadLine()) != null)
{
sb.Append(strLine);
Console.WriteLine(strLine);
} this writes all the data to the screen at one go. Is there away to
write one line at a time. Or possibly to resze the command widow as it
doesnt diplay all the data. Even if I scroll to the top, the first
parts missing.
Regards Robert
 
Hi, Using Console.Writeline, as
while ((strLine = stream.ReadLine()) != null)
{
sb.Append(strLine);
Console.WriteLine(strLine);
} this writes all the data to the screen at one go. Is there away to
write one line at a time.

This loop does, in fact, write one line at a time. To make it more
readable, perhaps you should either:

1) Redirect output to the 'more' command or a text file

or

2) Increase the size of your console buffer (Command Prompt properties)

or

3) Insert occasional "Press enter to continue" via:

---8<---
int lineCount = 0;
while ((strLine = stream.ReadLine()) != null)
{
sb.Append(strLine);
Console.WriteLine(strLine);
if (++lineCount % 24 == 0)
{
Console.Write("Press Enter to continue...");
Console.ReadLine();
}
}
--->---

-- Barry
 
What appears on the console is not necessarily synchronous with the write
operation. You need to do Console.Out.Flush to force it.

======================
Clive Dixon
Digita Ltd. (www.digita.com)
 
Clive Dixon said:
What appears on the console is not necessarily synchronous with the write
operation. You need to do Console.Out.Flush to force it.

According to Reflector, the Console Out stream has AutoFlush set to
true. The WriteLine(string) method calls Write(Char[],int,int) which
calls Flush() when AutoFlush is set to true.

-- Barry
 
I resize the Window by accessing the little icon of the Window and selecting
its properties.

<%= Clinton Gallagher
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top