在C#中,获取文件名的方法有以下几种方式:
string fileName = Path.GetFileName(filePath);
FileInfo fileInfo = new FileInfo(filePath);
string fileName = fileInfo.Name;
string fileName = filePath.Substring(filePath.LastIndexOf("\\") + 1);
Regex regex = new Regex(@"[^\\]*$");
Match match = regex.Match(filePath);
string fileName = match.Value;