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

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”

posted @ 2016-05-10 17:07  Raywang80s  阅读(463)  评论(0编辑  收藏  举报