又如从E:\aaa\bb\cc\dd.doc中取出dd.doc字串来?

解决方案 »

  1.   


    CFile file;
    file.Open("c:\\a.gif", CFile::modeRead);
    MessageBox(file.GetFileName());
      

  2.   

    CString filePath=_T("E:\aaa\bb\cc\dd.doc"),fileName=_T("");
    int i = filePath.ReverseFind(_T("\"));
    fileName = filePath.Right(i);
      

  3.   

    CString filePath=_T("E:\aaa\bb\cc\dd.doc");
    int len = filePath.GetLenth();
    CString fileName = filePath.Right(len-filePath.ReverseFind('\\')-1);
      

  4.   

    strPath = "C:\\path\\aa\\cc.txt"
    j = strPath.ReverseFind('\\');
    if( -1 != j )
    {
        strFileName = strPath.Right( (strPath.GetLength() - j - 1 ) );
    }
      

  5.   

    使用STL的stringstring strPath = _T("C:\path\aa\cc.txt");
    string strTemp;
    int iPos = string.rfind("\\");
    if(iPos != string::npos)
    {
        strTemp = strPath.substr(iPos + 1);
    }
      

  6.   

    不好意思,刚才字打错了^-^
    使用STL的stringstring strPath = _T("C:\path\aa\cc.txt");
    string strTemp;
    int iPos = strPath.rfind(_T("\\"));
    if(iPos != string::npos)
    {
        strTemp = strPath.substr(iPos + 1);
    }