There is no way (to my knowledge) to tell the
FindFirstFile/FindNextFile/FindClose to return files in any order other than
what you get.
So you need to read them in to an array or a ListView or whatever and then
sort them in the usual manner.
Dave O.
"Dave O." <nob...@nowhere.com> schrieb im Newsbeitrag
news:OaYx5jKS...@TK2MSFTNGP05.phx.gbl...
You could, but why bother, if you put the timestamp into a date variable you
can compare them directly in the sort routine.
If the data/times are stored as strings you'll need to convert them back to
dates for the sort, alternatively you could convert the date/time to doubles
and sort on those.
It's not all that easy to give exact examples because selecting which
routine would be optimum depends on many factors.
Dave O.
I just remembered you MUST apply the FileTimeToLocalFileTime API to the
FileTime structure before you save the value anywhere, this is because the
file stamps are stored in UDT (GMT no summer adjustment) and will need to be
adjusted to your locale.
Regards
Dave O.
Search for "FindFirstFile" at the following site:
The site is for VB6 despite its name. As for comparing times, you can use
CompareFileTime, or convert it to a Date data type. For the later, see
FileTimeToVBDate() function here:
http://vbnet.mvps.org/code/fileapi/fsoapicompare.htm
> 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
--
----------------------------------------------------------------------
Thorsten Albers albers(a)uni-freiburg.de
----------------------------------------------------------------------
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
"Larry Serflaten" <serf...@usinternet.com> schrieb im Newsbeitrag
news:uQhAe3RS...@TK2MSFTNGP05.phx.gbl...
What a completely superfluous performance killer...
"Thorsten Albers" <albe...@MOVEuni-freiburg.de> schrieb im Newsbeitrag
news:01c94bd0$282ba700$af01a8c0@Router...