Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting number of files on a drive

Tags:

c#

io

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

What is the fastest way to do so?

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

like image 300
animaonline Avatar asked Nov 25 '22 23:11

animaonline


1 Answers

Did you try import kernel32.dll and use it?

There is a good implementation example someone posted before here : https://stackoverflow.com/a/724184/912851. It might be worthwhile looking at.

Edit: The fastest one I saw in my life is this application. It uses ntfs journals. and within seconds it lists millions of files on my harddisk. I think they have a sdk and sources on C++ or c. Maybe you can create a managed dll and use on c#?

like image 65
Nesim Razon Avatar answered Dec 04 '22 09:12

Nesim Razon