class ExploreFold
{
static void Main(string[] args)
{
ExploreFold ef = new ExploreFold();
string theDirectory = @"D:\phproot";
DirectoryInfo dir = new DirectoryInfo(theDirectory);
ef.ExploreDirectory(dir);
Console.ReadLine();
}
private void ExploreDirectory(DirectoryInfo dir)
{
DirectoryInfo[] directories = dir.GetDirectories();
foreach (DirectoryInfo newDir in directories)
{
Console.WriteLine("目录名字{0}",newDir);
ExploreDirectory(newDir);
}
FileInfo[] filesInDir = dir.GetFiles();
foreach (FileInfo file in filesInDir)
{
Console.WriteLine("文件名字{0}",file.Name);
}
}
}