GetCurrentTime() and CFile option

早过忘川 提交于 2019-11-28 15:30:14

获取当前时间

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!