using System;
using System.IO;
class MainClass
{
public static void ShowDirectory(DirectoryInfo di, int intLevel)
{
string strPad = new String(' ', 2*intLevel);
Console.WriteLine(strPad + di.Name);
foreach (DirectoryInfo diChild in di.GetDirectories())
ShowDirectory(diChild, intLevel+1);
}
public static void Main()
{
DirectoryInfo di = new DirectoryInfo("c:\\");
ShowDirectory(di, 0);
}
}
Output
c:\
b
Documents and Settings
All Users
Application Data
Adobe
Acrobat
6.0
Replicate
Security
Microsoft
CoreCon
^CTerminate batch job (Y/N)? n