File.WriteAllLines : File : File Directory Stream C# Examples


C# Examples » File Directory Stream » File »

 

File.WriteAllLines









    
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);
                }
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo File Directory Stream
» File