GetCurrentTime() and CFile option

获取当前时间

CTime tm = CTime::GetCurrentTime();

将当前时间转换成sctring类型+.txt

1 CString str2;
2 str2.Format(_T("%d%d%d_%d%d%d.txt"),tm.GetYear(),tm.GetMonth(),tm.GetDay(),tm.GetHour(),tm.GetMinute(),tm.GetSecond());

将字符串定义为文件名称,并创建该文件,将编辑框内容写入文件内:

1 CFile c_flie;
2 if(c_flie.Open(str2,CFile::modeWrite|CFile::modeCreate))
3    {
4       CString m_str;
5       CEdit *pEdit = (CEdit *)this->GetDlgItem(IDC_EDIT15);
6       pEdit->GetWindowText(m_str);
7       c_flie.Write(m_str,m_str.GetLength());
8       c_flie.Close();
9     }

End

thanks.

posted on 2019-08-26 15:17  Milo_lu  阅读(109)  评论(0编辑  收藏  举报

导航