求救:用c++打不开文件了
大家帮帮忙啊
void CSfsfdsfDlg::OnOK()
{
UpdateData();
CStdioFile nameFile;
try
{
CString a;
nameFile.Open( "E:\\sfsfdsf\\plain.txt ",CFile::modeRead)){}
nameFile.ReadString(m_m);
nameFile.Close();
}
catch(CFileException)
{return;}
UpdateData(FALSE);
}
出错 DEBUG ASSERTION FAILD
[解决办法]
DEBUG ASSERTION FAILD
------
不是这段代码的问题
[解决办法]
void CADlg::OnButton3()
{
// TODO: Add your control notification handler code here
CString str;
UpdateData();
CStdioFile nameFile;
try
{
CString a;
nameFile.Open( "g:\\aa.txt ",CFile::modeRead);
nameFile.ReadString(str);
nameFile.Close();
}
catch(CFileException)
{return;}
UpdateData(FALSE);
CWnd *pWnd;
pWnd=this-> GetDlgItem(IDC_EDIT1);
pWnd-> SetWindowText(str);
}
上面是按钮的单击事件,IDC_EDIT1为编辑框,可以把aa.txt中的数据读到编辑框中.
运行无误.......