void CdispDataDlg::OnButtonRead()
{
// TODO: Add your control notification handler code here
//加载文档
CString strTempPathFile;
CString strTempFilter; //指定文件过滤器,此变量为临时的
strTempFilter = "选择数据文档 (*.txt)|*.txt||";
CFileDialog dlg(TRUE,
NULL,
NULL,
OFN_HIDEREADONLY | //隐藏只读选项
OFN_OVERWRITEPROMPT | //覆盖已有文件前提示
OFN_EXPLORER |
//如果没用这个风格,就是旧风格窗体
OFN_FILEMUSTEXIST, // 只能打开已存在的文件
strTempFilter);
dlg.m_ofn.lStructSize = sizeof (OPENFILENAME);
if (dlg.DoModal() == IDOK)
{
strTempPathFile = dlg.GetPathName(); //strPathName中是含有完整路径和文件名称的字符串
}
m_strData = strTempPathFile ; //记录在变量中
CFile fLotteryData;
//定义输入流变量接受文件数据
CString strSelRow;
//用于读取的时候存ar的内容
if (fData.Open ( strTempPathFile ,
CFile::modeRead ))//以只读方式打开,如果正确打开则go
{
int k = fData.GetLength();
CArchive art(&fData, CArchive::load);
if (art.
ar.close();
fData.Close();
}
else
{
AfxMessageBox ("选择数据文件不能打开" , MB_OK) ;
return ;
}
AfxMessageBox (strSelRow , MB_OK);
}
这里主要的问题是CArchive ar始终不能定义和构造,编译报ar不是一个类对象,我查查不出错误
|