C# sample code below:
class Program
{
static void Main(string[] args)
{
try
{
string dir = @"C:\";
TreeScan(dir);
Console.ReadLine();
}
catch(Exception e)
{
Console.WriteLine("Error:" + e.Message);
Console.Beep();
Console.ReadLine();
}
}
private static void TreeScan(string dir)
{
Console.WriteLine();
Console.WriteLine("Files in: " + dir);
foreach (string f in Directory.GetFiles(dir))
{
Console.WriteLine(f);
}
foreach (string d in Directory.GetDirectories(dir))
{
Console.WriteLine(d);
Console.WriteLine();
Console.WriteLine();
TreeScan(d);
}
}
}
class Program
{
static void Main(string[] args)
{
try
{
string dir = @"C:\";
TreeScan(dir);
Console.ReadLine();
}
catch(Exception e)
{
Console.WriteLine("Error:" + e.Message);
Console.Beep();
Console.ReadLine();
}
}
private static void TreeScan(string dir)
{
Console.WriteLine();
Console.WriteLine("Files in: " + dir);
foreach (string f in Directory.GetFiles(dir))
{
Console.WriteLine(f);
}
foreach (string d in Directory.GetDirectories(dir))
{
Console.WriteLine(d);
Console.WriteLine();
Console.WriteLine();
TreeScan(d);
}
}
}