public static string GetFileName(string fileName)
var result = Path.GetFileName(fileName);
if (!result.Contains('\\'))
return result.Split('\\').Last();
public static void Main()
Console.WriteLine(Path.GetFileName(@"C:\Users\baradma3\OneDrive - Novartis Pharma AG\Desktop\Quote CH-QU-387310.pdf"));
Console.WriteLine(GetFileName(@"C:\Users\baradma3\OneDrive - Novartis Pharma AG\Desktop\Quote CH-QU-387310.pdf"));