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

解决方案 »

  1.   

    char szRootDir[256];
    CString strPath;
    GetModuleFileName(NULL,szRootDir,256);//得到应用程序当前路径(包含程序名)
    strPath = szRootDir;
    int index = strPath.ReverseFind('\\');
    strPath = strPath.Mid(0,index);/剔除程序名
      

  2.   

    GetPathName - GetFileName 即可如下:
    CString strFullPath,strName,strWant;strFullPath = dlg.GetPathName();
    strName = dlg.GetFileName();strWant = strFullPath.Left( strFullPath.GetLength() - strName.GetLength() );
      

  3.   

    晕啊晕, 这种情况应该调用标准的 路径选择对话框SHBrowseForFolder()
    SHGetPathFromIDList();