我正在寻找一种方法从完整路径返回fileName但没有扩展名.
private static string ReturnFileNameWithoutExtension(string varFullPathToFile) {
string fileName = new FileInfo(varFullPathToFile).Name;
string extension = new FileInfo(varFullPathToFile).Extension;
return fileName.Replace(extension, "");
}
Run Code Online (Sandbox Code Playgroud)
是否有更多防弹解决方案,然后用空字符串替换扩展名?
Gon*_*alo 30
return Path.GetFileNameWithoutExtension (fullpath);
Run Code Online (Sandbox Code Playgroud)