using System;
using System.IO;

namespace streamwriter
{


    class Program
    {
        public const ushort nbelt=5;

        static void Main(string[] args)
        {   
            string path=@"G:\Temp\"; 
            string namefile="capteur.txt";
            
            if (!Directory.Exists (path))
                 Directory.CreateDirectory (path);

            FileInfo fic=new FileInfo(path+namefile);
            ConsoleKeyInfo keypressed;
            StreamWriter fictxt=null;

            if (fic.Exists)
            {
                Console.WriteLine("LE fichier" + namefile + " existe. Souhaitez vous l'écraser?");
                keypressed = Console.ReadKey(true);
                if (keypressed.KeyChar=='O')
                   fictxt=fic.CreateText();
                else
                    fictxt = fic.AppendText();
            }
            
            fictxt.WriteLine("capteur no;echantillon no;valeur");
             for (int i=0;i< nbelt; i++)
                    {
                    float val;
                    val = (float)Math.Sin((2*Math.PI/ nbelt)*i);
                    string concat = "capeur1;" + i + ";" + val;
                    fictxt.WriteLine(concat);
                    }
             fictxt.Close();
      
          }
       }
   
}
