By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,467 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,467 IT Pros & Developers. It's quick & easy.

writeline

P: n/a
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

May 16 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Ro********@yahoo.co.uk" <Ro********@yahoo.co.uk> wrote:
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
May 16 '06 #2

P: n/a
Console.Out.Flush() after each write?

======================
Clive Dixon
Digita Ltd. (www.digita.com)
<Ro********@yahoo.co.uk> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
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

May 16 '06 #3

P: n/a
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)
"Barry Kelly" <ba***********@gmail.com> wrote in message
news:dn********************************@4ax.com...
"Ro********@yahoo.co.uk" <Ro********@yahoo.co.uk> wrote:
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

May 16 '06 #4

P: n/a
Thankyou for your replys. This is a great help.
Regards Robert

May 16 '06 #5

P: n/a
"Clive Dixon" <cl*******************@digita.noluncheonmeat.com > wrote:
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
May 16 '06 #6

P: n/a
I resize the Window by accessing the little icon of the Window and selecting
its properties.

<%= Clinton Gallagher

<Ro********@yahoo.co.uk> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
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

May 16 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.