This code sample will return the file name from file path. Suppose if you have the full file path and you wanted to get only file name this method of Path class will give you the file name and removed the folder and sub folder name.
Path class is available in System.IO so do not forget to include the namespace.
string fileName = Path.GetFileName(@"c:\MyFolder\MyFile.txt");
And the result will be