//递归版本
static void GetDirectoryTree(ArrayList list, string path)
{
list.Add(path);
string[] paths;
try
{
paths = Directory.GetDirectories(path);
}
catch
{
return;
}
for (int i = 0; i < paths.Length; i++)
GetDirectoryTree(list, paths[i]);
}
//列表版本
static void GetDirectoryTree(ArrayList list, string path)
{
string[] paths;
list.Add(path);
for (int i = 0; i < list.Count; i++)
{
try
{
paths = Directory.GetDirectories(list[i].ToString());
}
catch
{
continue;
}
list.AddRange(paths);
}
}