操作函数:
void CFile_TestDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
CTime tm=CTime::GetCurrentTime();
CString str;
str.Format("%d年-%d月-%d日 %d:%d:%d",tm.GetYear(),tm.GetMonth(),tm.GetDay(),tm.GetHour(),tm.GetMinute(),tm.GetSecond());
CFile file;
file.Open("user.info",CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate);
file.SeekToEnd();
file.Write("\r\n"+str+"\r\n",str.GetLength()+4);
file.Write("\r\n"+m_strUser+"\r\n",m_strUser.GetLength()+4);
file.Write("\r\n"+m_strInfo+"\r\n",m_strInfo.GetLength()+4);
file.Close();
MessageBox("保存成功!","提示",MB_OK|MB_ICONEXCLAMATION);
UpdateData(FALSE);
//CDialog::OnOK();
}
时间: 2024-12-20 03:26:45