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

前端 未结 10 1548
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条回答
  •  Happy的楠姐
    2021-02-04 08:16

    If you are not afraid of calling win32 functions it might be worth trying FIndFirstFile then iterating with FindNextFile. This saves over overhead of allocating all those strings just to get a count.

提交回复
热议问题