CString   strPath;   
    
CFileDialog fileopen(true);
fileopen.m_ofn.lpstrTitle="打开文件";
fileopen.m_ofn.lpstrFilter="All Files(*.*)\0*.*\0\0";
   
   
if(IDOK==fileopen.DoModal())   
{   
   strPath=fileopen.GetPathName();      
} 这样只能得到文件所在的路径,得不到文件夹所在的路径!!! 怎样可以得到文件夹的路径呢???

解决方案 »

  1.   

    用代码不能实现吗??CFileDialog里面有这样的 函数没??
      

  2.   

     已经找到答案,谢谢!!! 
    CString   strPath;   
      BROWSEINFO   bi   ={0};     
      char   pszDisplayName[MAX_PATH]   ="\0";   
      bi.hwndOwner=NULL;   
      bi.pszDisplayName   =   pszDisplayName;   
      bi.lpszTitle="请选择目录:";   
      bi.ulFlags=BIF_RETURNONLYFSDIRS;   
      LPITEMIDLIST   lpIL   =   SHBrowseForFolder(&bi);   
      if(lpIL)   
      {           
          SHGetPathFromIDList(lpIL,bi.pszDisplayName);   
      }   
      else   
      {   
          strPath   =   _T("");
      }   
      strPath   = bi.pszDisplayName;