Link to home
Start Free TrialLog in
Avatar of DJ_AM_Juicebox
DJ_AM_Juicebox

asked on

getting selected filename with CFileDialog

Hi,
I'm using CFileDialog to let a user select multiple files for import into my application. I have the following code, but I want to know how to get just the filename of the current file being iterated over (if for example the user ctrl+clicks on multiple files to open:

void CMyApp::OnImportMultipleFiles()
{
    CFileDialog cfd(TRUE, ".txt", NULL, OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_NOCHANGEDIR, strFilters, this, sizeof(OPENFILENAME));

    if (cfd.DoModal() == IDOK) {
        POSITION pos = cfd.GetStartPosition();
        while (pos != NULL) {
             CString strNextPath = cfd.GetNextPathName(pos);

             // How do you get just the file name here of the current file being examined?
             CString strJustFileName = ????????????????;
         }
    }
}

Thanks
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW, you'll find the whole set of the helpers extremely useful: http://msdn2.microsoft.com/en-us/library/ms538767.aspx ("Shell Path Handling Functions")
Avatar of DJ_AM_Juicebox
DJ_AM_Juicebox

ASKER

excellent