您可以在这里快速查找:


 
您的位置: 编程学习 > asp.net教程 > 200601
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

文件搜索的实现(深度搜索)

rijing2000
System.Collections.Stack stackFile = new Stack(); /// /// 把要搜索的路径的文件夹全部压栈 /// /// public Stack FileList(string path) { string[] files = System.IO.Directory.GetDirectories(path); foreach(string file in files) { stackFile.Push(file); FileList(file); } return stackFile; } /// /// 把所有符合搜索条件的文件放到一个ArrayList里 /// /// 搜索的路径 /// 要搜索的文件 /// public ArrayList SearchFile(string path,string filter) { ArrayList array = new ArrayList(); Stack stack = new Stack(); //-----------对根目录进行搜索 string[] Rootfiles = System.IO.Directory.GetFileSystemEntries(path,filter); foreach(string file in Rootfiles) { System.IO.DirectoryInfo dirInfo = new DirectoryInfo(file); array.Add(dirInfo); } //----------- stack = this.FileList(path); if(stack.Count > 0) { while(stack.Count > 0) { string CurrentFile = stack.Pop().ToString(); string[] files = System.IO.Directory.GetFileSystemEntries(CurrentFile,filter); foreach(string file in files) { System.IO.DirectoryInfo dirInfo = new DirectoryInfo(file); array.Add(dirInfo); } } } return array; }