Directory picker dialog???
Hi,
Does any body know how to display a directory picker dialog in CSharp, I have seen many sample but they are so complex for a simple directory picker dialog, is there any simple directory picker sample. I have a very siple directory picker sample written using shell in
win32, can it be used in C-sharp if yes how?
static BOOL BrowseForDirectory(HWND hWnd, LPTSTR pSelectedPath, LPCTSTR pPrompt)
{
BOOL result = FALSE; // Assume failure
LPMALLOC pMalloc;
// Get's the Shell's default allocator
if (::SHGetMalloc(&pMalloc) == NOERROR)
{
BROWSEINFO bi;
TCHAR pszBuffer[MAX_PATH];
LPITEMIDLIST pidl;
bi.hwndOwner = hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = ;
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
if ((pidl = ::SHBrowseForFolder(&bi)) != NULL)
{
//get path from id
if (::SHGetPathFromIDList(pidl, pszBuffer))
{
_tcscpy(pSelectedPath, pszBuffer);
result = TRUE;
}
// Free the PIDL allocated by SHBrowseForFolder
pMalloc->Free(pidl);
}
// Release the shell's allocator
pMalloc->Release();
}
return result;
}