日志太大重命名一下。movefile()

if (dwSize > 5000000)
{
 //DeleteFile("111.log");
 SYSTEMTIME localTime;
 GetLocalTime(&localTime);

 TCHAR newFileName[MAX_PATH]; 
 memset(newFileName, 0, MAX_PATH * sizeof(TCHAR) );

 CString nameOnly = filename;
 int ind = nameOnly.Find(_T("."),0);
 if (ind != -1)
  nameOnly = nameOnly.Left(ind);
 wsprintf(newFileName, _T("%s_%04d%02d%02d_%02d%02d%02d%s"), nameOnly, 
  localTime.wYear, localTime.wMonth, localTime.wDay, 
  localTime.wHour, localTime.wMinute, localTime.wSecond, _T(".log"));

 MoveFile(filename, newFileName); 

} 


 

你可能感兴趣的:(积累,文件)