[DUG] Help in getting file age

Jianming Lin (FMI) jianmingl at fmi.co.nz
Fri May 1 10:05:40 NZST 2009


Hi, Vik,

 

Please note that:

 

If your hard disk is formatted in FAT format, then the raw file time
stored is not UTC time, instead it is local time.

 

// FindData.ftLastWriteTime   is stored as local time in hardisk of FAT
format

//----------------------------------------------------------------------
--------------------------------------------------

function FAT_GetFileUTC_Time(const FileName: string; var FileUTC_Time:
TSystemTime): boolean;

var Handle: THandle;

    FindData: TWin32FindData;

    LocalFileTime, UTC_FTime : TFileTime;

begin

  result := false;

  Handle := FindFirstFile(PChar(FileName), FindData);

  if Handle <> INVALID_HANDLE_VALUE then

  begin

    Windows.FindClose(Handle);

    if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
begin

      LocalFileTime := FindData.ftLastWriteTime;

      LocalFileTimeToFileTime(LocalFileTime, UTC_FTime); //convert to
UTC time

      FileTimeToSystemTime(UTC_FTime, FileUTC_Time);

      result := True;

    end;

  end;

end;

 

Regards

 

Jimmy

 

________________________________

From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Vikas...
Sent: Friday, 1 May 2009 2:07 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Help in getting file age

 

Dear Everyone,

I need a help in calculating the age of file.

I have checked the function file age. But it dint serve the purpose.

Reason being is. Let say i am sitting in India changed a file on 30th
April at 7:15pm. But on the other hand some one from america modifies
the same files at 9:30am on 30th April since we have time difference of
12 hours from US. So how do i make sure this file modified at 9:30am is
the new one.

Since according the file age filed modified at 7:15pm that is later one
is new. Which is not right.

Anyone ever worked on such things before.

I hope my query makes sense.

Cheers
Vik


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20090501/075cf4c0/attachment.html 


More information about the Delphi mailing list