var list = new List<string>();
FillFolderList("C:\\", list, 0, 3, 3);
public static void FillFolderList(string path, List<string> list, int current_level, int depth, int width)
{
list.Add(path);
if (current_level >= depth) return;
int current_width = 0;
try
{
foreach (var subdir in Directory.GetDirectories(path))
{
FillFolderList(subdir, list, current_level + 1, depth, width);
current_width++;
if (current_width > width) break;
}
}
catch (Exception)
{
}
}