Mega Code Archive

 
Categories / C# / File Stream
 

Read a single character

using System; using System.IO; class StrmRdrRead {     public static void Main()     {             FileInfo MyFile=new FileInfo(@"c:\csc.txt");             //Instantiate a StreamReader to read from the text file.             StreamReader sr=MyFile.OpenText();                          int FirstChar=sr.Read();             Console.WriteLine(FirstChar);             sr.Close();     } }