大家帮帮忙啊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
{
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
{
UpdateData();
CStdioFile nameFile;
nameFile.Open("E:\\sfsfdsf\\plain.txt",CFile::modeRead)
nameFile.ReadString(m_m);//从文件读一行,读入m_m
nameFile.Close();
UpdateData(FALSE);
}出错 DEBUG ASSERTION FAILD
------
不是这段代码的问题
CString strValue;
strValue = "select xx from table ";
CStdioFile f;
if ( f.Open( "g:\\a.doc" ,CFile::modeCreate|CFile::modeWrite ) )
{
f.WriteString( strValue );
f.Close();
}
{
// 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中的数据读到编辑框中.
运行无误.......
nameFile.Open("E:\\sfsfdsf\\plain.txt",CFile::modeRead)不行
我改了一下nameFile.Open("E:\\sfsfdsf\\plain.txt",CFile::modeRead,NULL)就可以了