How to quickly check if folder is empty (.NET)?

后端 未结 18 888
旧时难觅i
旧时难觅i 2020-12-02 08:22

I have to check, if directory on disk is empty. It means, that it does not contain any folders/files. I know, that there is a simple method. We get array of FileSystemInfo\'

18条回答
  •  庸人自扰
    2020-12-02 08:47

    I don't know about the performance statistics on this one, but have you tried using the Directory.GetFiles() static method ?

    It returns a string array containing filenames (not FileInfos) and you can check the length of the array in the same way as above.

提交回复
热议问题