Board index » delphi » Sort Files by Date ?

Sort Files by Date ?

Hi

How can I get a File list sorted by Date ?

Thank you
--

--
----------------------------------------------------------------------------
---------
Eyal Shkolnik  Software Engineer
                     Motorola Communications Israel Ltd.
e-mail:           shkol...@mcil.comm.mot.com
phone:           +972-3-565-9828 (office)
fax:               +972-3-565-8736
address:        3 Kermenezky St., Tel-Aviv 67899 Israel

 

Re:Sort Files by Date ?


In article <01bc8b77$6b6547e0$4c9b0...@vtu72.mcil.comm.mot.com> "Eyal" <shkol...@mcil.comm.mot.com> writes:

Quote
>How can I get a File list sorted by Date ?
>Thank you

You can do it but you will need to work at it a little.  What you need to do
is to write code that uses FindFirst, FindNext, and FindClose to assemble a
string-list of all the filenames, and also their dates (e.g. in the Object
pointers of the stringlist).

Then you must perform a sort; yourself.  And you will have to write, or buy,
the sort-routine because you'll have to specify your own comparison -- by date
rather than by value.

Once the sort is completed the values in the StringList can be placed into a
combo-box or whatever.

Re:Sort Files by Date ?


Quote
Sundial Services wrote:

> In article <01bc8b77$6b6547e0$4c9b0...@vtu72.mcil.comm.mot.com> "Eyal" <shkol...@mcil.comm.mot.com> writes:

> >How can I get a File list sorted by Date ?

> >Thank you

> You can do it but you will need to work at it a little.  What you need to do
> is to write code that uses FindFirst, FindNext, and FindClose to assemble a
> string-list of all the filenames, and also their dates (e.g. in the Object
> pointers of the stringlist).

> Then you must perform a sort; yourself.  And you will have to write, or buy,
> the sort-routine because you'll have to specify your own comparison -- by date
> rather than by value.

> Once the sort is completed the values in the StringList can be placed into a
> combo-box or whatever.

What's wrong with sorting the stringlist using its own sort method? Just
place the date in YYYYMMDD form as the first 8 chars of each string.
Piece of cake.

Robert

Other Threads