C#获取无扩展名的文件名
你可以使用 Path.GetFileNameWithoutExtension 方法来获取无扩展名的文件名。
以下是一个示例:
string filePath = "C:\\Documents\\example.txt";
string fileName = Path.GetFileNameWithoutExtension(filePath);
Console.WriteLine(fileName); // 输出 "example"
注意:你需要在代码中添加 using System.IO; 来引入 Path 类。
原文地址: https://www.cveoy.top/t/topic/hNZN 著作权归作者所有。请勿转载和采集!