void LogRecord(CString strlog,int nPlatformIndex)
{
SYSTEMTIME sys;
GetLocalTime( &sys );
CString t;
t.Format("[%02d_%02d_%02d_%02d_%02d_%03d]",sys.wMonth,sys.wDay,sys.wHour,sys.wMinute,sys.wSecond,sys.wMilliseconds);
CString strPath;
CString strTemp = "";
strTemp += t;
strTemp += strlog;
strTemp+= "\n";
FILE *stream;
CString strDir;
CFileFind findFile;
BOOL IsFild, IsDir;
IsFild = FALSE;
IsDir = FALSE;
strDir = "D:\\ASMLog";
IsFild = findFile.FindFile(strDir);
while (IsFild)
{
IsFild = findFile.FindNextFile();
IsDir = findFile.IsDirectory();
if(IsDir) break;
}
if (!IsDir)
{
if (!CreateDirectory(strDir, NULL))// 创建文件夹
{
return ;
}
}
strPath.Format("D:\\ASMLog\\Platform%d.txt",nPlatformIndex);
stream = fopen(strPath, _T("a+t"));
if (stream != NULL)
{
fwrite(strTemp, sizeof(TCHAR), strTemp.GetLength(), stream);
fclose(stream);
}
CFileStatus fs;
CFile::GetStatus(strPath,fs);
if (fs.m_size > 5000000)//1048576)
{
::DeleteFile(strPath);
}
}