使用CFileDialog取得文件路径,然后用CFile打开的

void CCFileDialog_CFileView::OnButton1()
{
 // TODO: Add your control notification handler code here
 CString m_szTmp;
  char buf[1000];
  CFileDialog dlg(TRUE,"mdl","*.txt");
  if(dlg.DoModal()==IDOK) {

   m_szEditText = dlg.GetPathName();
    CFile mfile;
     mfile.Open(dlg.GetPathName(), CFile::modeRead);
     mfile.Read(buf,sizeof(buf));
     m_szTmp = buf;
     //m_szEditText = m_szTmp;
     UpdateData(false);
     mfile.Close();
 }
 
}

原文地址:https://www.cnblogs.com/cy163/p/442893.html