Overloading the Directory.EnumerateFiles(string) method returns files contained directly in the specified directory. It does not return any subdirectories or files contained in it.
bool isEmpty = !Directory.EnumerateFiles(path).Any();
The advantage of EnumerateFiles over GetFiles is that file collection is renamed on demand, which means that the request will be successful as soon as the first file is returned (so as to avoid reading the rest of the files into the directory).
Douglas
source share