How to read text (all at once) from a text file in C#

1 Answer

0 votes
using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string file = File.ReadAllText("d:\\test.txt");

            Console.WriteLine(file);
        }
    }
}

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


answered Mar 11, 2015 by avibootz

Related questions

1 answer 265 views
1 answer 271 views
2 answers 422 views
1 answer 659 views
2 answers 476 views
1 answer 335 views
5 answers 631 views
...