File.WriteAllLines(String fileName, String[] lines) : File « System.IO « C# / C Sharp by API






File.WriteAllLines(String fileName, String[] lines)

  

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

class MainClass
{
    static void Main(string[] args)
    {
        string[] lines = new string[10];
        for (int i = 0; i < 10; i++)
        {
            lines[i] = String.Format( "This is line number {0}", i);
        }

        File.WriteAllLines(@"c:\test.txt", lines);

        foreach (string line in File.ReadAllLines(@"c:\test.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.ReadAllLines(String fileName)
9.File.SetAccessControl