使用Path.GetFileName方法可以轻松获取文件名称。以下是一个示例代码:

using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        string filePath = @"C:\AA\C.TXT";
        string fileName = Path.GetFileName(filePath);
        
        Console.WriteLine("File Name: " + fileName);
    }
}

输出结果为:

File Name: C.TXT
C# 获取文件名的简单方法 - Path.GetFileName

原文地址: https://www.cveoy.top/t/topic/p2di 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录