Is there a way (on windows using Delphi 2010) to get the number of files in a dirctory without actually traversing all files?
I want to implement a progress bar during some file system indexing operation. For that reason I need to know how many files are in the directory.
What is the fastest way to get the number of files in a directory?
I think the fastest way is to use the TDirectory.GetFiles method located in IOutils.pas. As the number of (visible) files in a directory may be different for each user, there is only a tiny chance that there is just a number to retrieve somehow.
The FindFirst/FindNext approach (which is wrapped in the above method) doesn’t actually traverse files, it only traverses entries in a table, so it might be faster than expected.