首页 > 其他 > 详细

GetCurrentTime() and CFile option

时间:2019-08-26 16:04:37      阅读:91      评论:0      收藏:0      [点我收藏+]

获取当前时间

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.

GetCurrentTime() and CFile option

原文:https://www.cnblogs.com/lumao1122-Milolu/p/11412705.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!