首页 > Windows开发 > 详细

【.Net】C# 根据绝对路径获取 带后缀文件名、后缀名、文件名、不带文件名的文件路径

时间:2017-07-12 14:44:02      阅读:508      评论:0      收藏:0      [点我收藏+]

1、c#根据绝对路径获取 带后缀文件名、后缀名、文件名。

 

 
1                 string str =" F:\test\Default.aspx";
2                 string filename = System.IO.Path.GetFileName(str);//文件名 “Default.aspx”
3                 string extension = System.IO.Path.GetExtension(str);//扩展名 “.aspx”
4                 string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(str);// 没有扩展名的文件名 “Default”
5 
6                 string directory=System.IO.Path.GetDirectoryName(physicalPath);
 

2、c#根据绝对路径获取 带后缀文件名、后缀名、文件名,使用 Split 函数。

1                 string str = =" F:\test\Default.aspx";
2                 char[] delimiterChars = { ‘.‘, ‘\\‘ };
3                 string[] Mystr = str.Split(delimiterChars);
4                 string sheetName = Mystr[Mystr.Length - 2];);// 没有扩展名的文件名 “Default”
 

【.Net】C# 根据绝对路径获取 带后缀文件名、后缀名、文件名、不带文件名的文件路径

原文:http://www.cnblogs.com/yanglang/p/7154886.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!