StreamReader.Peek() : StreamReader « System.IO « C# / C Sharp by API






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 ();
        }
    }

   
  








Related examples in the same category

1.new StreamReader(FileStream fs)
2.new StreamWriter(String filePath)
3.new StreamWriter(fs, Encoding.UTF8)
4.StreamReader.ReadLine()
5.StreamReader.ReadToEnd()