16,509
社区成员
发帖
与我相关
我的任务
分享
CString Directory[2]={"D:\\报文备份\\PAT\\*.sql*","D:\\报文备份\\SRC\\*.src*"};
CTime FileCreateTime,CurrentTime;
CurrentTime=CTime::GetCurrentTime();
CTimeSpan TimeSpan;
int i=0;
while(i>=0&&i<2)
{
CFileFind finder;
BOOL bWorking = finder.FindFile(Directory[i++]);
while (bWorking)
{
bWorking=finder.FindNextFile();
if(finder.GetLastWriteTime(FileCreateTime))
{
TimeSpan=CurrentTime-FileCreateTime;
if (TimeSpan.GetDays()>=6)
{
CString FileName = (LPCTSTR)finder.GetFileName();
DeleteFile(FileName);
}
}
}
}
}
BOOL DeleteFile(
LPCTSTR lpFileName // file name 摆明了应该叫filepathname 不怕误导人吗。。MSDN
);