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::OnImportMultipleFi les()
{
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
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::OnImportMultipleFi
{
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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")
ASKER
excellent