none
Pausing a console app after a screenful of information RRS feed

  • Question

  • My console app prints a large amount of information and I was trying to find out if it's possible to pause after one screenful of information is printed.

    When at a c:\ if you type dir /p   the page will pause after a screenful of info.  Is it possible to write something in C# to do the same thing?

    Thanks,

    Rich

    Thursday, July 18, 2013 8:37 PM

Answers

  • Have a look at the following:

    Console WindowsHeight

    CursorTop

    The code below will write a number on each line and pause when it gets to the bottom of the screen. Pressing enter will clear the screen and start from the top.

    for (int i = 0; i < 300; i++)
                {
                    Console.WriteLine(i);
                    if (Console.WindowHeight == Console.CursorTop)
                    {
                        Console.ReadLine();
                        Console.Clear();
                    }
                }

    • Marked as answer by R_i-c_h Friday, July 19, 2013 1:56 PM
    Friday, July 19, 2013 1:03 AM

All replies

  • After your printing/writing add a:

    Console.ReadLine();


    Thank you,

    Nick Metnik

    Please mark my response as helpful if it has helped you in any way or as the answer if it is a valid solution.
    Blog
    LinkedIn

    Thursday, July 18, 2013 11:07 PM
  • Have a look at the following:

    Console WindowsHeight

    CursorTop

    The code below will write a number on each line and pause when it gets to the bottom of the screen. Pressing enter will clear the screen and start from the top.

    for (int i = 0; i < 300; i++)
                {
                    Console.WriteLine(i);
                    if (Console.WindowHeight == Console.CursorTop)
                    {
                        Console.ReadLine();
                        Console.Clear();
                    }
                }

    • Marked as answer by R_i-c_h Friday, July 19, 2013 1:56 PM
    Friday, July 19, 2013 1:03 AM
  • That's pretty cool. It worked just like I was hoping it would. Thanks
    • Edited by R_i-c_h Friday, July 19, 2013 2:07 PM update
    Friday, July 19, 2013 1:57 PM
  • No love???

    Thank you,

    Nick Metnik

    Please mark my response as helpful if it has helped you in any way or as the answer if it is a valid solution.
    Blog
    LinkedIn

    Friday, July 19, 2013 3:42 PM