Click here to Skip to main content
15,921,989 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionFinding files older than a week Pin
m.dietz20-Nov-06 23:39
m.dietz20-Nov-06 23:39 
Hi,

In a current tool, that copies Sources from a server, zips them and sends the zip-File to another server, I have to delete the intermediate zip-Files stored locally about after a week (so that they still are available if the recipient claims a transfer failure).

I can't use CTime procedures for determining that week as the tool itself was created as Win32 console application without MFC support, so I tried to get the Local Time with GetLocalTime(&now), convert this to a FILETIME and compare it with the FILETIME got from the creation date of the file to decide wether this file is to be kept or deleted. According to the help pages FILETIME holds intervals of 100 nanosecond, so a week would calculate to 7(days)*24(hours)*60(minutes)*60(seconds)*1000(milliseconds)*1000(microseconds)*10(intervals of 100 nanoseconds) = 6048000000000 intervals.

The help pages tell me that I have to copy the FILETIME to a LARGE_INTEGER before I can compare the dates so I tried the following code:

LARGE_INTEGER liNow,liFile;
liNow.LowPart = ftNow.dwLowDateTime;
liNow.HighPart = ftNow.dwHighDateTime;

liFile.LowPart = localDateCreated.dwLowDateTime;
liFile.HighPart = localDateCreated.dwHighDateTime;

if(liNow.QuadPart - liFile.QuadPart > 6048000000000)
{ ... }


Now I have the problem that none of my files reach the deletion part of the code, even files two weeks old only have a difference of 1604372500. Is something wrong with my calculation, my conversion to LARGE_INTEGER or is the whole approach faulty?

Hope anyone can help me
Martin Dietz
QuestionRe: Finding files older than a week Pin
Viorel.21-Nov-06 1:37
Viorel.21-Nov-06 1:37 
AnswerRe: Finding files older than a week Pin
m.dietz21-Nov-06 3:57
m.dietz21-Nov-06 3:57 
QuestionRe: Finding files older than a week Pin
David Crow21-Nov-06 5:10
David Crow21-Nov-06 5:10 
AnswerRe: Finding files older than a week Pin
m.dietz21-Nov-06 20:23
m.dietz21-Nov-06 20:23 
AnswerRe: Finding files older than a week Pin
CPallini21-Nov-06 2:32
mveCPallini21-Nov-06 2:32 
GeneralRe: Finding files older than a week Pin
David Crow21-Nov-06 3:33
David Crow21-Nov-06 3:33 
GeneralRe: Finding files older than a week Pin
m.dietz21-Nov-06 4:04
m.dietz21-Nov-06 4:04 
GeneralRe: Finding files older than a week Pin
CPallini21-Nov-06 5:14
mveCPallini21-Nov-06 5:14 
GeneralRe: Finding files older than a week Pin
m.dietz21-Nov-06 20:31
m.dietz21-Nov-06 20:31 
GeneralRe: Finding files older than a week Pin
CPallini21-Nov-06 21:51
mveCPallini21-Nov-06 21:51 
QuestionATL::CSimpleStringT ?? [modified] Pin
dharani20-Nov-06 23:25
dharani20-Nov-06 23:25 
AnswerRe: ATL::CSimpleStringT ?? Pin
Viorel.20-Nov-06 23:34
Viorel.20-Nov-06 23:34 
GeneralRe: ATL::CSimpleStringT ?? Pin
dharani20-Nov-06 23:37
dharani20-Nov-06 23:37 
GeneralRe: ATL::CSimpleStringT ?? Pin
Rajesh R Subramanian20-Nov-06 23:57
professionalRajesh R Subramanian20-Nov-06 23:57 
AnswerRe: ATL::CSimpleStringT ?? Pin
James R. Twine21-Nov-06 0:36
James R. Twine21-Nov-06 0:36 
QuestionArray Question Pin
Programm3r20-Nov-06 22:53
Programm3r20-Nov-06 22:53 
AnswerRe: Array Question Pin
Programm3r20-Nov-06 23:47
Programm3r20-Nov-06 23:47 
GeneralRe: Array Question Pin
toxcct21-Nov-06 0:29
toxcct21-Nov-06 0:29 
QuestionVS 2005 Express C++ code in header files!? Pin
floenk20-Nov-06 22:46
floenk20-Nov-06 22:46 
AnswerRe: VS 2005 Express C++ code in header files!? Pin
Christian Graus20-Nov-06 23:03
protectorChristian Graus20-Nov-06 23:03 
QuestionCtreeCtrl Popupmenu Pin
harsha_123420-Nov-06 22:45
harsha_123420-Nov-06 22:45 
AnswerRe: CtreeCtrl Popupmenu Pin
Mila02520-Nov-06 22:57
Mila02520-Nov-06 22:57 
GeneralRe: CtreeCtrl Popupmenu Pin
harsha_123420-Nov-06 23:09
harsha_123420-Nov-06 23:09 
GeneralRe: CtreeCtrl Popupmenu Pin
Mila02520-Nov-06 23:31
Mila02520-Nov-06 23:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.