自己写了个日志类,发现写到日志文件里面全是数字
自己写了个日志类,发现写到日志文件里面全是数字 高手帮忙看看
CFile cf;
//CString m_CurrentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
CString strAppName;
GetModuleFileName(NULL, strAppName.GetBuffer(_MAX_PATH), _MAX_PATH);
strAppName.ReleaseBuffer();
int nPos = strAppName.ReverseFind('\\');
strAppName =strAppName.Left(nPos + 1);
//CFileStatus status;
CTime ctime;
//GetCurrentTime(&ctime);
ctime=CTime::GetCurrentTime();
//CString b=ctime.GetYear()+_T("-")+ctime::GetMonth()+_T("-")+ctime::GetDay()+_T(" ")+ctime::GetHour()+_T(":")+ctime::GetMinute()+_T(":")+ctime::GetSecond();
CString b=ctime.Format(_T("%Y-%m-%d %H%M%S"));
CFileStatus status;
CString sFile= strAppName+_T("\\log.txt");
CString msglog=b+_T(" ")+logmessage;
AfxMessageBox(msglog);
AfxMessageBox(sFile);
if(cf.Open(sFile,CFile::modeWrite))
{
try{
cf.SeekToEnd();
cf.Write(msglog,sizeof(msglog));
}
catch(CFileException*e)
{
e->Delete();
}
}
cf.Close();
[解决办法]
msglog.GetLength() 返回多少呢?