How do I find out how many files are in a directory?

后端 未结 4 765
名媛妹妹
名媛妹妹 2020-12-19 00:20

I need to get a count of the number of files in a directory. I could get the names of all the files in the directory using System.IO.Directory.GetFiles() and t

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 00:51

    There is no faster way. No matter what you use, it all boils down to FindFirstFile and FindNextFile Win32 calls.
    You could try using something like this, but it will probably take just as much time -- but maybe with a little less memory usage (= probably not worth it).

提交回复
热议问题