|
-
November 10th, 2004, 06:38 PM
#1
Number of days between two filetime structures...
I'm basically trying to see if a file is a certain number of days old, so that I can delete it... the code so far looks like:
Code:
FILETIME ft;
FILETIME ftFile;
bFinished = FALSE;
_snprintf(szSearch, sizeof(szPath), "%s\\*.*", szPath);
hSearch = FindFirstFile(szSearch, &wfd);
if (hSearch == INVALID_HANDLE_VALUE)
return FALSE;
while (!bFinished) {
if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
_snprintf(szFileName, sizeof(szFileName),
"%s\\%s", szPath, wfd.cFileName);
GetSystemTimeAsFileTime(&ft);
ftFile.dwHighDateTime = wfd.ftLastWriteTime.dwHighDateTime;
ftFile.dwLowDateTime = wfd.ftLastWriteTime.dwLowDateTime;
LocalFileTimeToFileTime(&(wfd.ftLastWriteTime));
/*NEED TO COMPARE HERE */
if (!DeleteFile(szFileName)) {
;
}
}
if (!FindNextFile(hSearch, &wfd)) {
if (GetLastError() == ERROR_NO_MORE_FILES) {
bFinished = TRUE;
}
else {
;
break;
}
}
}
if (!FindClose(hSearch)) {
;
}
return TRUE;
This code is not complete I know ... I need to be able to tell how many days old the file is, how do i get this from two FILETIME objects??
-
November 10th, 2004, 09:07 PM
#2
Re: Number of days between two filetime structures...
One solution is GetFileInformationByHandle().
Kuphryn
-
November 10th, 2004, 09:27 PM
#3
Re: Number of days between two filetime structures...
Code:
FILETIME ft1, ft2;
COleDateTime ot1(ft1);
COleDateTime ot2(ft2);
COleDateTimeSpan otspan = ot2-ot1;
otspan.GetTotalDays();
A.M.
My Latest Articles:
CCustomBitmapButton - An owner-draw button and a frame for the caption bar, in one class.
CCustomTabCtrl - A clone of the Excel tab sheet control.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|