用递归
private void getDirectories(string path)
{
string[] fileNames = Directory.GetFiles(path);
string[] directories = Directory.GetDirectories(path);
foreach (string file in fileNames)
{
Console.WriteLine("Filename:{0}",file);
}
foreach (string dir in directories)
{
Console.WriteLine("Directoriesname:{0}",dir);
getDirectories(dir);
}
}
Console.WriteLine这个地方你可以换成arraylist