🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16235

Sorted files list of a folder (FindFirst/FindNext/FindClose)

#16235
From: Lapo
Date: Thu, 22 May 2003 10:57
27 lines
1748 bytes
Hi all,
Somebody can help me on build a sorted files list of a selected folder?

I used the standard FindFirst/FindNext/FindClose functions to fill a
TStringList, then I use the Sorted property like in the snip below:

void GetSortedFileList(TStringList *FileList, AnsiString FolderName)
{
  TSearchRec SR;
  if(FindFirst("\\"+FolderName+"\\*.*", faAnyFile, SR)==0) {
    FileList->Clear();
    do {
        FileList->Add("\\"+FolderName+"\\"+SR.Name);
    } while(FindNext(SR)==0);
    FindClose(SR);
  }
  FileList->Sorted=true;
}

It works, but the main problem is that if I have a large amount of files, it
take a long time to terminate.

Somebody know a better way?

Thanks for the help

Lapo
Technical Details
Message-ID: <3eccacda@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!nntp1.fuse.net!canoe.uoregon.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,494d25904ac4f10a,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-22 04:36:02 PST
From: "Lapo" <lapoguidi@inwind.it>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Sorted files list of a folder (FindFirst/FindNext/FindClose)
Date: Thu, 22 May 2003 12:57:49 +0200
Lines: 29
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 62.98.56.51
Message-ID: <3eccacda@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1053600986 62.98.56.51 (22 May 2003 03:56:26 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!nntp1.fuse.net!canoe.uoregon.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail