Posted on 2012-08-12 14:51
小让 阅读(418)
评论(0) 编辑 收藏 引用
1 void CMyDlg::Log(CString strLog)
2 {
3 USES_CONVERSION;
4 CString strFileName;
5 CString strInfo;
6 CTime ctCurrent;
7 CString strTime;
8 ctCurrent = CTime::GetCurrentTime();
9 strTime = ctCurrent.Format("%m-%d %H:%M:%S");
10 strFileName.Format(TEXT("%s\\BuildLog_%s.log"), m_strConfigDir, m_strLogTime);
11 CFile file(strFileName, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeReadWrite);
12 file.SeekToEnd();
13 strInfo.Format(TEXT("%s %s\r\n"),strTime, strLog);
14 CStringA strTemp = W2A(strInfo);
15 file.Write(strTemp.GetBuffer(strTemp.GetLength()), strTemp.GetLength());
16 strTemp.ReleaseBuffer();
17 file.Flush();
18 file.Close();
19 }