比如:\\Mydocument\\Wuhan\\kk.dat
如何获得它的路径名:\\Mydocument\\Wuhan
这个路径名是存放在CString中还是CStringArray中??

解决方案 »

  1.   

    CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR,
    "所有图象文件(*.tif; *.jpg; *.bmp; *.tga)|*.tif; *.jpg; *.bmp; *.tga|TIFF 文件(*.tif)|*.tif|JPEG 文件(*.jpg)|*.jpg|Windows 位图(*.bmp)|*.bmp|Targa 文件(*.tga)|*.tga||"); if (dlg.DoModal() == IDOK)
    {
    m_bnotFindCap = TRUE;
    CString newName = dlg.GetPathName();
             }
      

  2.   

    dlg.GetPathName();获得的是全路径,如\\Mydocument\\Wuhan\\kk.dat我不需要全路径中的文件名(kk.dat),只需要它的路径\\Mydocument\\Wuhan这个部分。该怎么处理呢??
      

  3.   

    自己写阿:TCHAR curPath[256];
             StrCopy(curPath, (LPCSTR)dlg.GetPathName());
    TCHAR *cp = curPath + strlen(curPath) -1;
    while(*cp != '\\') cp --;
    *cp = 0;
      

  4.   

    curPath 就是你要的了,真是懒阿
      

  5.   

    在得到path后CString strPath = dlg.GetPathName();
    strPath = strPath.Left(strPath.ReverseFind('\\'));
      

  6.   

    用strrchr(),我觉得这个函数还比较好用