c#文件路径的获取

string fullPath = @"\WebSite1\Default.aspx";

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

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

System.IO.Path.GetFileNam(filePath)       //返回带扩展名的文件名 
System.IO.Path.GetFileNameWithoutExtension(filePath)     //返回不带扩展名的文件名 
System.IO.Path.GetDirectoryName(filePath)     //返回文件所在目录

 

posted @ 2016-11-07 09:56  小小高  阅读(238)  评论(0编辑  收藏  举报