麻烦大家看一下这代码,还有,保存文件的代码又应该怎么样写呢?
这是打开文件的代码
void CReceptDBMSView::OnButtonOpen()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(TRUE,"rpt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"Êվݴ浵(*.rpt)|*.rpt|ËùÓÐÎļþ(*.*)|*.*||",this);
if(dlg.DoModal()==IDCANCEL)
return;
CString filename=dlg.GetPathName();
CString str;
CFile file;
if(file.Open(filename,CFile::modeReadWrite)==0)
{
str="´ò¿ªÎļþ "+filename+" ʧ°Ü!!!";
AfxMessageBox(str);
return;
}
CArchive ar(&file,CArchive::load);
if(this->m_ReceptsCount!=0)
{
this->m_pSet->MoveFirst();
while(!this->m_pSet->IsEOF())
{
this->m_pSet->Delete();
this->m_pSet->MoveNext();
}
}
ar.Close();
file.Close();
if(AfxGetApp()->OpenDocumentFile(filename)==NULL)
AfxMessageBox("´ò¿ªÓëÊվݴ浵ͬÃûµÄÎļþʧ°Ü!!!");
}