DirectoryInfo d = new DirectoryInfo(path);
if() // there is a file in the directory do something.
I can get the files if there exists any, but I also have to consider the possbility that there is no file inside that subfolder path.
string[] files = System.IO.Directory.GetFiles(path);
if (files.Length == 0)
Console.WriteLine("Empty");
else
Console.WriteLine("Not Empty");
Using EnumerateFiles
var fileCount = Directory.EnumerateFiles(@"C:\").Count();
if (fileCount == 0)
Console.WriteLine("Empty");
else
Console.WriteLine("Not Empty");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With