I have this code
public static void Main(string[] args)
{
var dir = @"C:\\temp\\TestDir";
PrintDirectoryTree(dir, 2, new string\[\] { "folder3" });
}
public static void PrintDirectoryTree(string directory, int lvl, string\[\] excludedFolders = null, string lvlSeperator = "")
{
excludedFolders = excludedFolders ?? new string\[0\];
foreach (string f in Directory.GetFiles(directory))
{
Console.WriteLine(lvlSeperator + Path.GetFileName(f));
}
foreach (string d in Directory.GetDirectories(directory))
{
Console.WriteLine(lvlSeperator + "-" + Path.GetFileName(d));
if (lvl > 0 && Array.IndexOf(excludedFolders, Path.GetFileName(d)) < 0)
{
PrintDirectoryTree(d, lvl - 1, excludedFolders, lvlSeperator + " ");
}
}
}
How can I display just the first 10 files in all directories found