How to read entire text file with TextReader in C#

1 Answer

0 votes
using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (TextReader reader = File.OpenText("d:\\test.txt"))
            {
                string text = reader.ReadToEnd();
                
                Console.WriteLine(text);
            }
        }
    }
}

/*
run:
   
Text File Line one
Text File Line two
Text File Line three

*/


answered Mar 12, 2015 by avibootz

Related questions

1 answer 171 views
1 answer 203 views
1 answer 280 views
1 answer 303 views
1 answer 291 views
1 answer 226 views
1 answer 253 views
...