static void Test() {
string path = "E:\\软件包\\net安装包\\4_NDP472-KB4054531-Web.exe";
Console.WriteLine("目录:" + Path.GetDirectoryName(path)); //E:\软件包\net安装包
Console.WriteLine("后缀:" + Path.GetExtension(path)); //.exe
Console.WriteLine("文件名:" + Path.GetFileName(path)); //4_NDP472-KB4054531-Web.exe
Console.WriteLine("不含后缀文件名:" + Path.GetFileNameWithoutExtension(path)); //4_NDP472-KB4054531-Web
Console.WriteLine("跟目录:" + Path.GetPathRoot(path)); //E:\
Console.WriteLine("更改后缀:" + Path.ChangeExtension(path, ".bin")); //E:\\软件包\\net安装包\\4_NDP472-KB4054531-Web.bin
}
09-22
1100
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-07
1293
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-29
810
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交