Ed Covney
asked on
Delphi FileTime
I can get the times (create, Access, Modifiy) of one file and change a second file's datetimes accordingly. However, I'm having a devil of a time displaying that datetime as a string. See below.
FHIn := FileOpen(FNOut,fmShareDeny Write or fmOpenWrite);
GetFileTime(FHIn,@FCDo,@FA Do,@FMDo);
FileClose(FHIn);
FHOut := FileOpen(FNOut,fmShareDeny Write or fmOpenWrite);
SetFileTime(FHOut,@FCDo,@F ADo,@FMDo) ;
FileClose(FHOut);
// - all working so far
showmessage(FormatDateTime ('yyyy/mm/ dd hh:mm:ss',FMDo)+' '+FNOut)
// this displays - 1899/12/30 00:00:00 (and the file name)
What is the most direct way to display a file's date in string format?
TIA - Ed
FHIn := FileOpen(FNOut,fmShareDeny
GetFileTime(FHIn,@FCDo,@FA
FileClose(FHIn);
FHOut := FileOpen(FNOut,fmShareDeny
SetFileTime(FHOut,@FCDo,@F
FileClose(FHOut);
// - all working so far
showmessage(FormatDateTime
// this displays - 1899/12/30 00:00:00 (and the file name)
What is the most direct way to display a file's date in string format?
TIA - Ed
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Check function DSiGetFileTimes(const fileName: string; var creationTime, lastAccessTime, lastModificationTime: TDateTime): boolean from below url to get all file dates...
How to get create/last modified dates of a file in Delphi?
Use DateToStr to convert TDateTime values into string values...
How to get create/last modified dates of a file in Delphi?
Use DateToStr to convert TDateTime values into string values...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
rinfo - thanks for trying, but "FileTimeToSystemTime(F1_l astWrite,S ysTimeStru ct)"
produces an error (Delphi XE2):
"E2250 There is no overloaded version of 'FileTimeToSystemTime' that
can be called with these arguments"
which I've seen a lot of lately through all my trials . . .
produces an error (Delphi XE2):
"E2250 There is no overloaded version of 'FileTimeToSystemTime' that
can be called with these arguments"
which I've seen a lot of lately through all my trials . . .
ASKER
Thommy -
Thank you !! Who would of thought of fileage? You, of course! I'll certainly add that to my bag 'o tricks.
Although it only produces dates (no times). I checked out "fileage" (Delphi Help) which in turn led me to a slight mod of your code (to enable times):
FHInt := FileAge(FNIn);
FInDateTime := FileDateToDateTime(FHInt);
strDIn := DateTimeToStr(FInDateTime );
showmessage(strDIn);
File datetimes vs system datetimes vs local times, etal; confuses me to no end. So I'll certainly check out you link.
Thanks again - Ed
Thank you !! Who would of thought of fileage? You, of course! I'll certainly add that to my bag 'o tricks.
Although it only produces dates (no times). I checked out "fileage" (Delphi Help) which in turn led me to a slight mod of your code (to enable times):
FHInt := FileAge(FNIn);
FInDateTime := FileDateToDateTime(FHInt);
strDIn := DateTimeToStr(FInDateTime );
showmessage(strDIn);
File datetimes vs system datetimes vs local times, etal; confuses me to no end. So I'll certainly check out you link.
Thanks again - Ed
ASKER
FHIn := FileOpen(FNIn,fmShareDenyW