Exercise
More
Objetive
Create a program which behaves like the Unix command "more": it must display the contents of a text file, and ask the user to press Enter each time the screen is full.
As a simple approach, you can display the lines truncated to 79 characters, and stop after each 24 lines
Example Code
using System;
using System.IO;
namespace More
{
class Program
{
static void Main(string[] args)
{
}
public void ShowData(string urlFile)
{
StreamReader fichero = new StreamReader(urlFile);
string line;
int count = 0;
do
{
line = fichero.ReadLine();
if (line != null)
{
if (count % 24 == 0)
Console.ReadLine();
if (line.Length > 79)
line = line.Substring(0, 79);
Console.WriteLine(line);
}
count++;
}
while (line != null);
fichero.Close();
}
}
}