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 262 views
1 answer 184 views
1 answer 214 views
1 answer 264 views
1 answer 2,735 views
1 answer 196 views
...