Thanks, but I think I don't need to use FileTimeToLocalFileTime() just to
sort the files by date/time, am I right?
Regards
Peter
>>> Thanks for your fast answer!
>>> What is the best way to sort the files by date/time:
[quoted text clipped - 8 lines]
> Regards
> Dave O.
Thorsten Albers - 17 Nov 2008 22:23 GMT
> Thanks, but I think I don't need to use FileTimeToLocalFileTime() just to
> sort the files by date/time, am I right?
You don't. In addition it is not necessary to call CompareFileTime() since
a FIILETIME is just an increasing 64 bit number. The call to
CompareFileTime() needs more time than a comparison done in you code.
If FT_A.dwHighDateTime <> FT_B.dwHighDateTime Then
If FT_A.dwHighDateTime >= 0 Then
If FT_B.dwHighDateTime >= 0 Then
If FT_A.dwHighDateTime > FT_B.dwHighDateTime Then
' A >= 0 / B >= 0 - A > B
Else
' A >= 0 / B >= 0 - A < B
End If
Else
' A >= 0 / B < 0: A < B
End If
ElseIf FT_B.dwHighDateTime >= 0 Then
' A < 0 / B >= 0: A > B
ElseIf FT_A.dwHighDateTime > FT_B.dwHighDateTime Then
' A < 0 / B < 0 - A > B
Else
' A < 0 / B < 0 - A < B
End If
ElseIf FT_A.dwLowDateTime >= 0 Then
If FT_B.dwLowDateTime >= 0 Then
If FT_A.dwLowDateTime > FT_B.dwLowDateTime Then
' A >= 0 / B >= 0 - A > B
Else
' A >= 0 / B >= 0 - A < B
End If
Else
' A >= 0 / B < 0: A < B
End If
ElseIf FT_B.dwLowDateTime >= 0 Then
' A < 0 / B >= 0: A > B
ElseIf FT_A.dwLowDateTime > FT_B.dwLowDateTime Then
' A < 0 / B < 0 - A > B
Else
' A < 0 / B < 0 - A < B
End If

Signature
----------------------------------------------------------------------
Thorsten Albers albers(a)uni-freiburg.de
----------------------------------------------------------------------
Larry Serflaten - 18 Nov 2008 00:35 GMT
> Thanks, but I think I don't need to use FileTimeToLocalFileTime() just to
> sort the files by date/time, am I right?
> Regards
You might convert the values to the Decimal type which can handle
those large numbers. Then you just compare the two (Decimal)
values. Conversion might be like: (not tested)
Private Function ToDecimal(FileTime As FileTimeType) As Variant
Dim hi As Long, lo As Long
Dim hx As String
hx = Right$("0000000" & Hex(FileTime.Hi), 8)
hi = Val("&H" & Left$(hx, 4) & "&")
lo = Val("&H" & Right$(hx, 4) & "&")
ToDecimal = hi * CDec(65536) + lo
hx = Right$("0000000" & Hex(FileTime.Lo), 8)
hi = Val("&H" & Left$(hx, 4) & "&")
lo = Val("&H" & Right$(hx, 4) & "&")
ToDecimal = ToDecimal * CDec(4294967296#) + hi * CDec(65536) + lo
End Function
The conversion to Hex was used to properly treat the sign bit as used
in an unsigned value. Other (all numeric) methods of conversion may be
quicker....
LFS
Peter - 21 Nov 2008 06:55 GMT
Just want to Thank you all for your answers.
I solved the problem by using a Function "FileTimetoserial" which creates a
Date-Variable out of the FileTime Structure.
Then I used these date values in my sort routine.
Regards
Peter
>> Thanks, but I think I don't need to use FileTimeToLocalFileTime() just to
>> sort the files by date/time, am I right?
[quoted text clipped - 22 lines]
>
> LFS
Thorsten Albers - 21 Nov 2008 11:56 GMT
Peter <peter_l@myrealbox.com> schrieb im Beitrag
<gg5m10$cvn$1@mail1.sbs.de>...
> Just want to Thank you all for your answers.
> I solved the problem by using a Function "FileTimetoserial" which creates a
> Date-Variable out of the FileTime Structure.
> Then I used these date values in my sort routine.
What a completely superfluous performance killer...

Signature
----------------------------------------------------------------------
Thorsten Albers albers(a)uni-freiburg.de
----------------------------------------------------------------------
Peter - 24 Nov 2008 15:27 GMT
You are right. But I found out that I need the filetime in a variable "as
date" later in my code so I thought I convert it to date immediately.
Regards
Peter
> Peter <peter_l@myrealbox.com> schrieb im Beitrag
> <gg5m10$cvn$1@mail1.sbs.de>...
[quoted text clipped - 5 lines]
>
> What a completely superfluous performance killer...