How to get the length of a 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.Length); // 60
            }
        }
    }
}

/*
run:
   
60

*/


answered Mar 12, 2015 by avibootz

Related questions

1 answer 260 views
1 answer 181 views
1 answer 212 views
1 answer 259 views
1 answer 2,732 views
1 answer 191 views
...