大家帮帮忙啊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

解决方案 »

  1.   

    nameFile.Open("E:\\sfsfdsf\\plain.txt",CFile::modeRead)){}这句是什么意思啊,又多了个),后面的{}有什么用!
      

  2.   

    不好意思void CSfsfdsfDlg::OnOK() 
    {
    UpdateData();
    CStdioFile nameFile;
    nameFile.Open("E:\\sfsfdsf\\plain.txt",CFile::modeRead)
             nameFile.ReadString(m_m);//从文件读一行,读入m_m
              nameFile.Close();
             UpdateData(FALSE);
    }出错 DEBUG ASSERTION FAILD
      

  3.   

    DEBUG ASSERTION FAILD
    ------
    不是这段代码的问题
      

  4.   

    这里有个往文件中写数据的,对比一下,看能否找到错误.
    CString strValue;
    strValue = "select xx from table ";
    CStdioFile f;
    if ( f.Open( "g:\\a.doc" ,CFile::modeCreate|CFile::modeWrite  ) )
    {
    f.WriteString( strValue );
    f.Close();
    }
      

  5.   

    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中的数据读到编辑框中.
    运行无误.......
      

  6.   

    谢谢大家,问题我找到了
    nameFile.Open("E:\\sfsfdsf\\plain.txt",CFile::modeRead)不行
    我改了一下nameFile.Open("E:\\sfsfdsf\\plain.txt",CFile::modeRead,NULL)就可以了