Use StreamReader to read a line from a text file : StreamReader : File Directory Stream C# Examples


C# Examples » File Directory Stream » StreamReader »

 

Use StreamReader to read a line from a text file









    
using  System;
using  System.IO;

class  MainClass
{
        public  static  void  Main(string[]  args)
        {
                        
                        string  filename  =  "c:\\file.txt";
                        
                        FileStream  f  =  new  FileStream(filename,  FileMode.Open);
                        StreamReader  stream  =  new  StreamReader(f);
                        
                        string  line;
                        line  =  stream.ReadLine();        //  header  line
                        Console.WriteLine(line);
                        
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo File Directory Stream
» StreamReader