I want the full path name.
-
The following code will give me a dialog box that will allow a user to choose a directroy. It does return me the directory name, but I also need the full path to the directory. How do I get the full path to the directory?????? Thanks in advance. void CSwapObjectsView::DoDirectoryDialog(CString& strDir) { char szDisplayName[MAX_PATH] = ""; char szTitle[] = "Choose a directory"; BROWSEINFO x; memset(&x, NULL, sizeof(BROWSEINFO)); x.hwndOwner = this->m_hWnd; x.pszDisplayName = szDisplayName; x.lpszTitle = szTitle; x.ulFlags = BIF_RETURNONLYFSDIRS ; SHBrowseForFolder(&x);
-
The following code will give me a dialog box that will allow a user to choose a directroy. It does return me the directory name, but I also need the full path to the directory. How do I get the full path to the directory?????? Thanks in advance. void CSwapObjectsView::DoDirectoryDialog(CString& strDir) { char szDisplayName[MAX_PATH] = ""; char szTitle[] = "Choose a directory"; BROWSEINFO x; memset(&x, NULL, sizeof(BROWSEINFO)); x.hwndOwner = this->m_hWnd; x.pszDisplayName = szDisplayName; x.lpszTitle = szTitle; x.ulFlags = BIF_RETURNONLYFSDIRS ; SHBrowseForFolder(&x);
Here's the bare-bones code to do it. Adding error handling is left as an exercise to the reader. ;)
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
TCHAR szDir[MAX_PATH];pidl = SHBrowseForFolder(&x);
SHGetPathFromIDList ( pidl, szDir );SHGetMalloc(&pMalloc);
pMalloc->Free(pidl);
pMalloc->Release();