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??




Reply With Quote