. Home Feedback Contents Search

File Browse 

Up Next

CFileDialog

MFC comes with a class for presenting the user with a manual file browsing interface, CFileDialog. It was originally intended to encapsulate the two most common reasons a user might wish to browse for a file, to find one to open or to determine where to save data in a file.

CString CMyClass::GetFile( CString csInput, CString csExt )
{
    CString csReturn;
    CFileDialog dlg( true, csExt, csFile, OFN_FILEMUSTEXIST );
    if ( IDOK == dlg.DoModal() )
        csReturn = dlg.GetPathName();

    return csReturn;
}

 

Up Next

Hit Counter