求递归算法扫描文件夹信息
做文件分发系统,需要写一个递归算法扫描文件夹信息,由于知识有限,希望会的高手指点我这个菜鸟啊,谢谢
--------------------编程问答--------------------
用递归是很不好的思路,应该用多线程...
--------------------编程问答--------------------
static void Main(string[] args)
{
d("d:\\aaa");
Console.WriteLine("\n\n程序执行结束,按任意键关闭窗口!");
Console.ReadKey();
}
static void d(string path)
{
string[] dirs = Directory.GetDirectories(path);
Console.WriteLine("\n" + path);
foreach (string s in dirs)
{
Console.WriteLine(" " + s);
}
foreach (string s in dirs)
{
d(s);
}
}
运行结果:
d:\aaa
d:\aaa\gouwu
d:\aaa\guanli
d:\aaa\zuopin
d:\aaa\gouwu
d:\aaa\gouwu\Connections
d:\aaa\gouwu\image
d:\aaa\gouwu\pic
d:\aaa\gouwu\Templates
d:\aaa\gouwu\_notes
d:\aaa\gouwu\Connections
d:\aaa\gouwu\image
d:\aaa\gouwu\image\_notes
d:\aaa\gouwu\image\_notes
d:\aaa\gouwu\pic
d:\aaa\gouwu\Templates
d:\aaa\gouwu\_notes
d:\aaa\guanli
d:\aaa\guanli\picture
d:\aaa\guanli\picture
d:\aaa\zuopin
d:\aaa\zuopin\data
d:\aaa\zuopin\data
程序执行结束,按任意键关闭窗口!
补充:.NET技术 , C#