BOOLCDictManagerDlg::ReadData()
{
CStdioFilefile;
CFileExceptionexp;
if(file.Open(“c:\\ziku.txt”,CFile::typeText|CFile::modeRead,&exp) == FALSE)
{
CStringsMsg;
exp.GetErrorMessage(sMsg.GetBuffer(1024),1024);
sMsg.ReleaseBuffer();
MessageBox(sMsg,"错误",MB_OK|MB_ICONERROR);
returnFALSE;
}
CStringsValue;
while(file.ReadString(sValue))
{//sVal是读出的一行数据,也可以用如下形式:
//char cBuf[1024];
//while(file.ReadString(cBuf,1024))
}
}
写文件
BOOLCDictManagerDlg::SaveToFile()
{
CStdioFilefile;
CFileExceptionexp;
if(file.Open(“c:\\ziku.txt”,CFile::modeCreate|CFile::modeWrite|CFile::typeText,&exp) == FALSE)
{
CStringsMsg;
exp.GetErrorMessage(sMsg.GetBuffer(1024),1024);
sMsg.ReleaseBuffer();
MessageBox(sMsg,"错误",MB_OK|MB_ICONERROR);
returnFALSE;
}
file.WriteString("#BEGIN__[B]\r\n");//写一行数据
returnTRUE;
}