下面是一个函数可以使用CFileDialog取得文件路径,然后用CFile打开的.
(其中,m_szEditText是已经绑定到一个CEdit里面的CString)
CString m_szTmp;
char buf[1000];
CFileDialog dlg(TRUE,"mdl","*.mdl");
if(dlg.DoModal()==IDOK) {
CFile mfile;
mfile.Open(dlg.GetPathName(), CFile::modeRead);
mfile.Read(buf,sizeof(buf));
m_szTmp = buf;
m_szEditText = m_szTmp;
mfile.Close();
}
UpdateData(FALSE);
---------------------------------------------
CFileDialog Class MembersData Members
The Windows OPENFILENAME structure. Provides access to basic file dialog box parameters.
Construction
Constructs a CFileDialog object.
Operations
Displays the dialog box and allows the user to make a selection.
Returns the full path of the selected file.
Returns the filename of the selected file.
Returns the file extension of the selected file.
Returns the title of the selected file.
Returns the full path of the next selected file.
Returns the read-only status of the selected file.
Returns the position of the first element of the filename list.
Overridables
Called when a share violation occurs.
Called to validate the filename entered in the dialog box.
Called when the list box selection changes.
Called to handle the WM_NOTIFY CDN_INITDONE message.
Called to handle the WM_NOTIFY CDN_SELCHANGE message.
Called to handle the WM_NOTIFY CDN_FOLDERCHANGE message.
Called to handle the WM_NOTIFY CDN_TYPECHANGE message.