How to read a text file line by line in C#

1 Answer

0 votes
using System;
using System.IO;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            StreamReader file = new StreamReader("c:\\temp.txt");

            while ((line = file.ReadLine()) != null)
            {
                Console.WriteLine(line);
            }

            file.Close();
        }
    }
}



answered Jul 1, 2014 by avibootz

Related questions

1 answer 154 views
154 views asked Dec 23, 2016 by avibootz
1 answer 214 views
1 answer 173 views
1 answer 174 views
174 views asked Apr 8, 2021 by avibootz
2 answers 327 views
327 views asked Jan 4, 2021 by avibootz
...