public static string GetName(string file, bool extension)
{
if (extension) return Path.GetFileName(file);
else return Path.GetFileNameWithoutExtension(file);
}
//Retourne le nom du fichier avec son extension
MessageBox.Show(GetName(@"C:\Windows\Calc.exe", true));
//Retourne le nom du fichier sans son extension
MessageBox.Show(GetName(@"C:\Windows\Calc.exe", false));