Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
could you please help me to select the files from inside folder.
when i tried its selection only folder names not files not listing

What I have tried:

BROWSEINFO   bi;
    ZeroMemory(&bi, sizeof(bi));
    TCHAR   szDisplayName[MAX_PATH] = { 0 };
    bi.hwndOwner = NULL;
    bi.pidlRoot = NULL;
    bi.pszDisplayName = szDisplayName;
    bi.lpszTitle = _T("Please select a file  :");
    bi.ulFlags = BIF_RETURNONLYFSDIRS;
    bi.lParam = NULL;
    bi.iImage = 0;
    LPITEMIDLIST   pidl = SHBrowseForFolder(&bi);
    TCHAR   szPathName[MAX_PATH] = { 0 };
    if (NULL != pidl)
    {
        BOOL bRet = SHGetPathFromIDList(pidl, szPathName);
        if (FALSE == bRet)
            return;
    }


the above is showing only folder name
could you please help me here
Posted
Updated 19-Dec-17 20:50pm
v2

You must show a file selction dialog and not a folder selection dialog as the function name SHBrowseForFolder tells you.

Windows provides common dialogs including a file dialog (see Common Dialogs (Windows)[^]). With MFC you can also use the CFileDialog Class[^] which encapsulates the common file dialog.
 
Share this answer
 
If You change bi.ulFlags = BIF_RETURNONLYFSDIRS; to
bi.ulFlags = BIF_BROWSEINCLUDEFILES; you will have also the files in the browsing list!
 
Share this answer
 
Comments
OriginalGriff 8-Oct-21 3:33am    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 8 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more!
Answering old questions can be seen as rep-point hunting, which is a form of site abuse. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900