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 168 views
1 answer 174 views
2 answers 263 views
1 answer 553 views
2 answers 327 views
1 answer 221 views
5 answers 433 views
...