Can you please explain File Time Stamps to me?

  • Thread starter Thread starter Joseph Geretz
  • Start date Start date
J

Joseph Geretz

I'm getting all confused with the various types of filetimes; local and UTC
if I understand that much correctly.

FileInfo FI = new FileInfo(FileSpec);

According to my understanding, I would expect

FI.LastWriteTime.ToFileTimeUtc();
to be equal to
FI.LastWriteTimeUtc.ToFileTime();

According to my (mistaken) understanding, the first gets the local LastWrite
time and then converts it to a UTC FileTime. The second one gets the Last
write time in UTC and then simply converts it to a FileTime. So why do these
come out different?

FI.LastWriteTime
FI.LastWriteTimeUtc
FI.LastWriteTime.ToFileTime
FI.LastWriteTime.ToFileTimeUtc
FI.LastWriteTimeUtc.ToFileTime

FI.LastWriteTimeUtc.ToFileTimeUtc

Specifically, I need to compare the times for two files on separate servers.
I'm pulling my information via Web Services and the two servers may be in
different time zones. How can I get the last write timestamp from both files
in a unified format so that I can see which file was written to more
recently?

Thanks for your help!

- Joe Geretz -
 
if I understand that much correctly.
FileInfo FI = new FileInfo(FileSpec);

According to my understanding, I would expect

FI.LastWriteTime.ToFileTimeUtc();
to be equal to
FI.LastWriteTimeUtc.ToFileTime();
uh...
I think you fall prey of the 1.1 bug.
in 1.1 DateTime value don't know their zone, and every time you call
ToFileTimeUtc() you get a different value.
In 2.0 DateTime now their time zone (and you could know it through the
'Kind' property) and I expect this bug to be fixed.
 
Back
Top