You can use System.IO.Path.GetFileName
to do this.
E.g.,
string[] files = Directory.GetFiles(dir);
foreach(string file in files)
Console.WriteLine(Path.GetFileName(file));
While you could use FileInfo
, it is much more heavyweight than the approach you are already using (just retrieving file paths). So I would suggest you stick with GetFiles
unless you need the additional functionality of the FileInfo
class.