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 146 views
146 views asked Dec 23, 2016 by avibootz
1 answer 204 views
1 answer 159 views
1 answer 163 views
163 views asked Apr 8, 2021 by avibootz
2 answers 311 views
311 views asked Jan 4, 2021 by avibootz
...