如上.

解决方案 »

  1.   

    CFileDialog::GetPathName()可以取得到
      

  2.   

    当选一个文件时,GetPathName()得到的是文件名;
    当选多个文件时,GetPathName()得到的是目录名;
    我想知道系统有没有提供只能选择目录的对话筐?
      

  3.   

    SHBrowseForFolder
    ===================
    void XXX::OnBrowseFolder() 
    {
    // TODO: Add your control notification handler code here
    BROWSEINFO bi;
    TCHAR szFolder[MAX_PATH];
    memset(&bi,0,sizeof(bi));
    bi.hwndOwner = this->GetSafeHwnd();
    bi.lpszTitle = _T("Select a folder...");
    bi.pidlRoot = NULL;
    bi.pszDisplayName = (LPTSTR)&szFolder;
    bi.lpfn = NULL;
    bi.lParam = (LPARAM)m_strPrjPath.GetBuffer(0);
    LPITEMIDLIST pidl;
    pidl = SHBrowseForFolder(&bi); if (pidl == NULL)
    {
    return;
    }
    else
    {
    SHGetPathFromIDList(pidl, (LPTSTR)&szFolder);
    GetDlgItem(IDC_LOCATION)->SetWindowText(szFolder);
    m_strPrjPath = szFolder;
    }
    }
      

  4.   

    CString str;
    BROWSEINFO bi;
    char name[MAX_PATH];
    ZeroMemory(&bi,sizeof(BROWSEINFO));
    bi.hwndOwner=GetSafeHwnd();
    bi.pszDisplayName=name;
    bi.lpszTitle="请选择你的文件夹:";
    bi.ulFlags=BIF_RETURNONLYFSDIRS;
    LPITEMIDLIST idl=SHBrowseForFolder(&bi);
    if(idl==NULL)
    return;
    SHGetPathFromIDList(idl,str.GetBuffer(MAX_PATH));
    str.ReleaseBuffer();
    m_Path=str;
    if(str.GetAt(str.GetLength()-1)!='\\')
    m_Path+="\\";