File.ReadAllLines(String fileName) : File « System.IO « C# / C Sharp by API






File.ReadAllLines(String fileName)

  

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

class MainClass
{
    static void Main(string[] args)
    {
        StreamWriter writer = new StreamWriter(@"c:\myfile.txt");
        for (int i = 0; i < 3; i++)
        {
            writer.Write(i.ToString());
        }
        writer.Flush();
        writer.Close();

        foreach (string line in File.ReadAllLines(@"c:\myfile.txt"))
        {
            Console.WriteLine(line);
        }
    }
}

   
    
  








Related examples in the same category

1.File.CreateText(String fileName)
2.File.Delete
3.File.Exists(String fileName)
4.File.GetLastAccessTime
5.File.OpenRead
6.File.OpenText
7.File.OpenWrite
8.File.SetAccessControl
9.File.WriteAllLines(String fileName, String[] lines)