Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: CBXE8 - Fastest way to get number of files and sub-folders in a folder ?


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Oct 7, 2015 4:45 PM Last Post By: Remy Lebeau (Te...
GAI CHEW KAI

Posts: 117
Registered: 7/25/14
CBXE8 - Fastest way to get number of files and sub-folders in a folder ?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2015 6:33 AM
Embarcadero® C++Builder XE8 Version 22.0.19027.8951 and Indy 10.
Window 10 Pro x64
Android 4.1.2

QUESTIONS:

1. Is there a way to get the number of files and folders within a directory, eg. ./*.* ?

The reason is, enumerating the path "./" and its sub-folders will take time to complete. I really needs a solution to obtain a folder information such as below:

GetDirectoryInfo( UnicodeString( L"./usr" ), &iFolderCount, &iFileCount );

Is there such method or any other solutions is greatly appreciated.

Please advise.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: CBXE8 - Fastest way to get number of files and sub-folders in a folder? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2015 9:09 AM   in response to: GAI CHEW KAI in response to: GAI CHEW KAI
GAI wrote:

Is there a way to get the number of files and folders within a
directory, eg. ./*.* ?

Not directly, no. You have to enumerate through the individual files/directories.
You can use TDirectory::GetFiles() and TDirectory::GetDirectories() for
that.

The reason is, enumerating the path "./" and its sub-folders will
take time to complete.

Sorry, there is no other option, especially across multiple platforms. At
least on Windows, you could use the Win32 API to access the filesystem directly
and read its metadata. But on Android, you are out of luck on that.

--
Remy Lebeau (TeamB)
GAI CHEW KAI

Posts: 117
Registered: 7/25/14
Re: CBXE8 - Fastest way to get number of files and sub-folders in a folder? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2015 3:28 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thanks Remy,

I noticed something from majority file browser applications mostly using first level of folder content scanning and reporting,
only when user selected particular folder, then it re-scan that folder at one level deeper :)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: CBXE8 - Fastest way to get number of files and sub-folders in afolder? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2015 4:45 PM   in response to: GAI CHEW KAI in response to: GAI CHEW KAI
GAI wrote:

I noticed something from majority file browser applications mostly
using first level of folder content scanning and reporting, only
when user selected particular folder, then it re-scan that folder
at one level deeper :)

Yes, that is easier to manage and faster to execute than scanning the whole
drive at one time.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02