>你可以参考这个</P>http://www.matrixstudio.org/bbs/dispbbs.asp?boardID=10&ID=34&page=4
>using System;
> Class1 t = new Class1();</P>
> string theDirectory = @"C:\WINDOWS";</P>
> DirectoryInfo dir = new DirectoryInfo(theDirectory);</P>
> t.ExploreDirectory(dir);# f! b: V7 |/ j8 J8 s8 U
> private void ExploreDirectory(DirectoryInfo dir)8 T/ ^' Z* `% j- a3 A' r( e- `/ g
> for (int i = 0; i < indentLevel; i++)
> Console.WriteLine("[{0}] {1} [{2}]\n", indentLevel, dir.Name, dir.LastWriteTime);</P>8 l. M6 \$ J6 _* n% G. s7 o: z& H4 j
>// FileInfo[] fileInDir = dir.GetFiles();
> DirectoryInfo[] directories = dir.GetDirectories();
> indentLevel--;
> private static int dirCounter = 1;//计数目录
>部分注释是查看文件夹中的文件,输出文件夹和文件的名字和创建时间,要查看文件,只要去掉注释就可以。</P>
>另外,程序的部分代码是为输出到Console而写,你只要简单重构一下,即可得到适合你的代码。</P>[em01][em01][em01]| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |