Numerotation devant un fichier.

Numerotation devant un fichier. - C#/.NET managed - Programmation

Marsh Posté le 18-01-2009 à 18:42:14    

Bonjour,  
J'aimerai pouvoir supprimer un fichier en tappant simplement le numero du qui apparait et pas par le nom.. ( pour eviter des fautes d'orthographe ou autre erreur.. )
 
quelqu'un à une idée?
 

Code :
  1. static void Supprimer_qcm()
  2.         {
  3.             string supp_fic;
  4.             string fileToDelete;
  5.             Console.Clear();
  6.             En_tete();
  7.             Console.WriteLine("\t\t Saisissez le nom du fichier pour le supprimer" );
  8.             Console.WriteLine("________________________________________________________________________________" );
  9.             int i = 1;
  10.        
  11.             try
  12.             {
  13.                 DirectoryInfo var_rep = new DirectoryInfo(chemin);
  14.                 FileInfo[] mesfichiers = var_rep.GetFiles();
  15.                 foreach (FileInfo fi in mesfichiers)
  16.                 {
  17.                     System.Console.WriteLine(i+". "+fi.Name);
  18.                     i++;
  19.                 }
  20.             }
  21.             catch (Exception e)
  22.             {
  23.                 System.Console.WriteLine(e.Message);
  24.                 System.Console.ReadLine();
  25.             }
  26.             supp_fic = Console.ReadLine();
  27.             fileToDelete = chemin + @"\" + supp_fic;
  28.             if (File.Exists(fileToDelete))
  29.             {
  30.                 System.IO.File.Delete(fileToDelete);
  31.                 Console.WriteLine("Le fichier " + supp_fic + " a été supprimé" );
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine("Le fichier n'existe pas ou a été supprimé" );
  36.             }
  37.                 Console.ReadKey();
  38.                 partie_admin();
  39.            
  40.         }


 
Merci.

Reply

Marsh Posté le 18-01-2009 à 18:42:14   

Reply

Marsh Posté le 18-01-2009 à 18:45:03    

Int32.TryParse(String, Int32)


Message édité par masklinn le 18-01-2009 à 18:45:25

---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed