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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Did you try import
kernel32.dlland 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#?