There has to be a more efficient approach? Especially since windows index
services are running on most PCs. Is the OS really that handicapped such
that it doesn't keep a pointer count?
>> the managed way is :
>>
[quoted text clipped - 20 lines]
>
> -cd
Damien - 23 Jun 2006 08:06 GMT
> There has to be a more efficient approach? Especially since windows index
> services are running on most PCs. Is the OS really that handicapped such
> that it doesn't keep a pointer count?
>
>From some of what you posted, I gather you're trying to count the
number of files on a disk, rather than just the number within a
particular directory?
If this is the case, then go into the root of your system drive,
highlight everything, and bring up the properties. Notice how the count
of files is goes up, as the system traverses all of the directories and
does file counts? If something as simple as the properties page is
having to do this work, it pretty much indicates to me that there isn't
a faster method available in Windows, or they'd have done it there
already.
Damien
Carl Daniel [VC++ MVP] - 23 Jun 2006 14:19 GMT
> There has to be a more efficient approach? Especially since windows
> index services are running on most PCs. Is the OS really that
> handicapped such that it doesn't keep a pointer count?
I don't know if I'd call it handicapped, but yes - there's no documented
better way. The total file count simply isn't kept by the file system. In
the metadata of NTFS there are counts of useful things (useful to the
filesystem) like the MFT size, and the number of used MFT records, but the
total file count is apparently not useful enough to be worth the effort of
maintaining it.
I suspect that a low-level scan of the MFT to count file records would be
more efficient, but there's no documented APIs for doing that.
-cd