I have program which writes to database which folders are full or empty. Now I\'m using
bool hasFiles=false;
(Directory.GetFiles(path).Length >0) ? hasFiles=
If you are using .Net 4.0 have a look at the EnumerateFiles method. http://msdn.microsoft.com/en-us/library/dd413232(v=VS.100).aspx
The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of FileInfo objects before the whole collection is returned; when you use GetFiles, you must wait for the whole array of FileInfo objects to be returned before you can access the array. Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
This way not all the files are retrieved from the folder, if the enumerator has at least 1 file the folder is not empty