标签:happy csdn str root 文件的 lin 链接 ring details
//一个文件目录
string filePath = "C:\\JiYF\\BenXH\\BenXHCMS.xml";
Console.WriteLine("该文件的目录:"+filePath);
string str = "获取文件的全路径:" + Path.GetFullPath(filePath); //-->C:\JiYF\BenXH\BenXHCMS.xml
Console.WriteLine(str);
str = "获取文件所在的目录:" + Path.GetDirectoryName(filePath); //-->C:\JiYF\BenXH
Console.WriteLine(str);
str = "获取文件的名称含有后缀:" + Path.GetFileName(filePath); //-->BenXHCMS.xml
Console.WriteLine(str);
str = "获取文件的名称没有后缀:" + Path.GetFileNameWithoutExtension(filePath); //-->BenXHCMS
Console.WriteLine(str);
str = "获取路径的后缀扩展名称:" + Path.GetExtension(filePath); //-->.xml
Console.WriteLine(str);
str = "获取路径的根目录:" + Path.GetPathRoot(filePath); //-->C:\
Console.WriteLine(str);
Console.ReadKey();
---------------------
作者:adliy_happy
来源:CSDN
原文:https://blog.csdn.net/adliy_happy/article/details/78354441
版权声明:本文为博主原创文章,转载请附上博文链接!
标签:happy csdn str root 文件的 lin 链接 ring details
原文地址:https://www.cnblogs.com/xiaohua19920/p/10743770.html