C# 截取路径中的文件名

 
string fullPath="f:studyimages(002.jpg ";
int index=fullPath.LastIndexOf("");
string fileName=fullPath.SubString(index+1);//文件名
string fileExtensition=System.IO.Path.GetExtension(fullPath);//扩展名






string strFile =
@"c:abce.jpg";
       
string strEx = System.IO.Path.GetExtension(strFile); //  返回 .jpg

string strName = System.IO.Path.GetFileName(strFile); //返回 e.jpg


string  imgname = FileUpload1.PostedFile.FileName;
             
string imgType = imgname.Substring(imgname.LastIndexOf(".") +
1);
             
string quanname =DateTime.Now.ToString("yyyyMMddHHmmss")+imgname.LastIndexOf("\")+"."+imgType ;
             
if ("gif"
!= imgType &&
"jpg"
!= imgType &&
"GIF"
!= imgType &&
"JPG"
!= imgType)
               
...{
                    Response.Write(
"<script>alert('请选择gif,jpg格式的文件!');</script>");
                   
return;
                }





string test="C:\Documents and Settings\Lenovo User\桌面\code.txt";
           
int i;
            String FileName;
            i
=test.LastIndexOf("\");         
            FileName
=test.Substring(i +
1);     
Sinoprise Network Studio
        ----专注.NET技术