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

前端 未结 10 1426
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 07:54

    If I'm using a slowish high-level language, and portability wasn't a big concern, I'd be tempted to try calling an external program (eg `ls | wc`.first.to_i if using ruby and unix), but then I'd check whether it does the job any better.

提交回复
热议问题