If you don't have to use SDELETE, try messing with the following program. It deletes empty directories from the base directory. You could use this as a starting block and reverse the logic to delete directories with content. Then if you must use SDELETE, you can call it to delete a single directory when one is found.
Hogan
using System;
using System.IO;
namespace EmptyDirectory
{
class Program
{
static void Main(string[] args)
{
RecursiveSearch(@"c:\music");
Console.WriteLine("Finished.");
Console.ReadLine();
}
private static void RecursiveSearch(string folder)
{
foreach (string s in Directory.EnumerateDirectories(folder, "*", SearchOption.AllDirectories))
{
if (Directory.GetFiles(s).Length == 0 && Directory.GetDirectories(s, "*", SearchOption.TopDirectoryOnly).Length == 0)
{
Directory.Delete(s);
Console.WriteLine("Deleted: " + s);
}
}
}
}
}