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






StreamReader.ReadToEnd()

 
using System;
using System.IO;

  public class StreamReaderAndWriter {
    static void Main(string[] args)
    {
      StreamReader MyStreamReader = new StreamReader(@"c:\Testing.txt");

      FileStream MyFileStream = new FileStream(@"c:\Testing.txt", FileMode.Open, FileAccess.Read, FileShare.None);
      StreamReader MyStreamReader2 = new StreamReader(MyFileStream);

      MyFileStream.Close();
      MyStreamReader2.Close();

      string MyStringReader = MyStreamReader.ReadLine();

      string MyStringReadToEOF = MyStreamReader.ReadToEnd();

      int[] MyArrayOfCharacters = new int[100];

      for (int i = 0; i < 99; i++)
      {
        MyArrayOfCharacters[i] = MyStreamReader.Read();
      }

      MyStreamReader.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.Peek()
5.StreamReader.ReadLine()