Quicker (quickest?) way to get number of files in a directory with over 200,000 files

前端 未结 10 1421
Happy的楠姐
Happy的楠姐 2021-02-04 07:35

I have some directories containing test data, typically over 200,000 small (~4k) files per directory.

I am using the following C# code to get the number of files in a di

10条回答
  •  孤城傲影
    2021-02-04 08:06

    You could use System.Management and WMI's class "cim_datafile", just run the following query in WMI, you can also use Linq to Wmi but i didn't try it

    select * from cim_datafile where drive='c:' and path='\\SomeDirectory\\' 
    

    I guess it will work faster

提交回复
热议问题