Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simplest method to create an OpenFileDialog and return the pathname to edittext box using MFC applications

Tags:

c++

mfc

How to create a MFC application in which I want to implement an OpenFileDialog box and the resultant path name to be displayed on the edittext box.

like image 996
abejoe Avatar asked Dec 07 '25 01:12

abejoe


1 Answers

Here is an example that will help you get started:

const TCHAR szFilter[] = _T("CSV Files (*.csv)|*.csv|All Files (*.*)|*.*||");
CFileDialog dlg(FALSE, _T("csv"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, this);    
if(dlg.DoModal() == IDOK)
{
    CString sFilePath = dlg.GetPathName();
    m_FilePathEditBox.SetWindowText(sFilePath);
}
like image 200
Andrew Komiagin Avatar answered Dec 08 '25 14:12

Andrew Komiagin