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\'
My code is amazing it just took 00:00:00.0007143 less than milisecond with 34 file in folder
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); bool IsEmptyDirectory = (Directory.GetFiles("d:\\pdf").Length == 0); sw.Stop(); Console.WriteLine(sw.Elapsed);