Saturday, May 21, 2011

Read all lines in array

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Myproject
{
    class Program
    {
       
        class ReadAll
        {
            public static void Main(string[] args)
            {
                try
                {
                    string[] lines = System.IO.File.ReadAllLines(@"C:\myfile.txt");
                    Console.Out.WriteLine("contents = " + lines.Length);
                    Console.In.ReadLine();
                }
                catch(Exception)
                {
                }
            }
        }
    }
}

Next 

No comments:

Post a Comment