How to extract file name from file path name?

Viewed 69184

I need to move all files from source folder to destination folder. How can I easily extract file name from file path name?

string newPath = "C:\\NewPath";

string[] filePaths = Directory.GetFiles(_configSection.ImportFilePath);
foreach (string filePath in filePaths)
{
  // extract file name and add new path 
  File.Delete(filePath);
}
5 Answers
Related