Counting the number of files on disk

I need my program to count the number of files on disk.

What is the fastest way to do this?

Directory.GetFiles () is not an alternative since it is very slow.

+5
source share
3 answers

Have you tried to import kernel32.dlland use it?

There is a good example of which was published earlier: fooobar.com/questions/66305 / ... . Perhaps worth a look.

Edit: , , . ntfs. . , sdk ++ c. , dll #?

+2
Func<string, int> files = null;
files = p => Directory.GetFiles(p).Length() + Directory.GetDirectories(p).Select(p1 => files(p1));

int count = files(@"c:\");

, linqy!

0

you can read the log of the USN drive, it is very fast, but you need administrator rights

0
source

All Articles