Saber el nombre de un fichero conociendo toda su ruta

1998 vistas

Para poder extraer el nombre de un fichero conociendo su path completo tendremos que usar la clase System.IO.Path y su método GetFileName.



csharp
  1. string fileName = "C:\\unFihero.txt";
  2. string name = System.IO.Path.GetFileName(fileName);
  3. Console.WriteLine(name);