当前位置: 代码迷 >> WinCE >> 自各儿写了个日志类,发现写到日志文件里面全是数字
  详细解决方案

自各儿写了个日志类,发现写到日志文件里面全是数字

热度:31   发布时间:2016-04-28 12:49:55.0
自己写了个日志类,发现写到日志文件里面全是数字
自己写了个日志类,发现写到日志文件里面全是数字 高手帮忙看看
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() 返回多少呢?
  相关解决方案