>你可以参考这个</P>http://www.matrixstudio.org/bbs/dispbbs.asp?boardID=10&ID=34&page=4
>using System;( a; L: H2 @- _2 R a, M A4 h g
> Class1 t = new Class1();</P>1 y: I. k& o" x' f" D
> string theDirectory = @"C:\WINDOWS";</P>* Q) o. ~, g4 n; U: T) G. ?6 Q
> DirectoryInfo dir = new DirectoryInfo(theDirectory);</P>0 {1 {/ ^& }( M4 F1 P$ R3 U
> t.ExploreDirectory(dir);9 B K5 [$ g7 B: w
> private void ExploreDirectory(DirectoryInfo dir), W* |& t( |3 |& ^5 Y y0 @
> for (int i = 0; i < indentLevel; i++)6 D- F p+ [1 d' Q8 @4 [# h/ E
> Console.WriteLine("[{0}] {1} [{2}]\n", indentLevel, dir.Name, dir.LastWriteTime);</P>+ K" E6 r& u0 F2 R
>// FileInfo[] fileInDir = dir.GetFiles();3 A$ _4 D$ H- p7 X, l7 X
> DirectoryInfo[] directories = dir.GetDirectories();
> indentLevel--;# b- B7 \4 M, A+ |; _6 E
> private static int dirCounter = 1;//计数目录
>部分注释是查看文件夹中的文件,输出文件夹和文件的名字和创建时间,要查看文件,只要去掉注释就可以。</P>
>另外,程序的部分代码是为输出到Console而写,你只要简单重构一下,即可得到适合你的代码。</P>[em01][em01][em01]9 t3 }7 W4 q, u; \6 ?& L# B| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |