码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2016-05-10 18:18:28      阅读:356      评论:0      收藏:0      [点我收藏+]

标签:

zz   C#根据绝对路径获取 带后缀文件名、后缀名、文件名

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

                string str =" F:\test\Default.aspx";
                string filename = System.IO.Path.GetFileName(str);//文件名 “Default.aspx”
                string extension = System.IO.Path.GetExtension(str);//扩展名 “.aspx”
                string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(str);// 没有扩展名的文件名 “Default”

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

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

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

标签:

原文地址:http://www.cnblogs.com/Raywang80s/p/5478506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!