Possible Duplicate:
How to get the sort order in Delphi as in Windows Explorer?
I am trying to scan a directory, but I can't get it to Sort by File Name.
Example, say if I have these Filenames in a folder:
- File1
- File2
- File3
- File4
- File5
- File6
- File7
- File8
- File9
- File10
- File11
- File12
- File13
- File14
- File15
- File16
- File17
- File18
- File19
- File20
- File21
- File22
If I use something like this:
var
SL: TStringList;
SR: TSearchRec;
begin
SL := TStringList.Create;
try
if FindFirst(Path + '*.*', faAnyFile and not faDirectory and not faHidden, SR) = 0 then
repeat
SL.Add(Path + SR.Name)
until FindNext(SR) <> 0;
FindClose(SR);
// handle the filenames..
finally
SL.Free;
end;
end;
The result will be:
- File10
- File11
- File12
- File13
- File14
- File15
- File16
- File17
- File18
- File19
- File2
- File20
- File21
- File22
- File3
- File4
- File5
- File6
- File7
- File8
- File9
It should be sorted by Filename (as I wrote in the first Filename list example).
I bet this is really simple but I cannot see it, what do I need to do to sort this?
Thanks.