Mega Code Archive

 
Categories / C# by API / System IO
 

StreamReader Peek()

using System; using System.IO;     public class StrmRdr     {         static public void Main (string [] args)         {             FileStream strm;             StreamReader reader;             strm = new FileStream ("test.txt", FileMode.Open, FileAccess.Read);             reader = new StreamReader (strm);             while (reader.Peek() >= 0)             {                 string text = reader.ReadLine ();                 Console.WriteLine (text);             }             reader.Close ();             strm.Close ();         }     }