Read data in line by line

image_pdfimage_print
   
  
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;
        }
    }
}

   
     


This entry was posted in File Stream. Bookmark the permalink.