Read data in line by line : Stream Read Write : File Stream C# Source Code


Custom Search

C# Source Code » File Stream » Stream Read Write »

 

Read data in line by line








    
 
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

class Program {
    static void Main(string[] args) {
        string strLine;

        try {
            FileStream aFile = new FileStream("Log.txt", FileMode.Open);
            StreamReader sr = new StreamReader(aFile);
            strLine = sr.ReadLine();
            while (strLine != null) {
                Console.WriteLine(strLine);
                strLine = sr.ReadLine();
            }
            sr.Close();
        } catch (IOException e) {
            Console.WriteLine("An IO exception has been thrown!");
            Console.WriteLine(e.ToString());
            return;
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo File Stream
» Stream Read Write