text: Proposed exercise.
  Output
  Solution
  using System; using System.IO; class InvertText { static void Main() { Console.Write("Enter name file: "); string name = Console.ReadLine(); if (File.Exists(name)) { StreamReader file = File.OpenText(name); string line; int count=0; do { line = file.ReadLine(); if (line != null) count++; } while (line != null); file.Close(); string[] lines = new string[count]; count = 0; line = ""; file = File.OpenText(name); do { line = file.ReadLine(); if (line != null) { lines[count] = line; count++; } } while (line != null); file.Close(); StreamWriter myfileWr = File.CreateText(name + ".dat"); for (int i = lines.Length - 1; i > 0; i--) myfileWr.WriteLine( lines[i] ); myfileWr.Close(); } else Console.WriteLine("Error"); } }