I am trying to delete all of the empty directories in a directory. I have code that works:
private static void processDirectory(string startLocation)
foreach (var directory in Directory.GetDirectories(startLocation))
if (Directory.GetFiles(directory).Length == 0 && Directory.GetDirectories(directory).Length == 0)
log.Rows.Add(DateTime.Now, "Success", "The directory named " + directory + " was deleted because it was empty.");
which works good other than the line about adding the row to the log will not work because it is out of the context.
I tried putting this block of code into the main part of the code, but it will not work.