class ExploreFold { static void Main(string[] args) { ExploreFold ef = new ExploreFold(); string theDirectory = @"D:\phproot"; DirectoryInfo dir = new DirectoryInfo(theDirectory); ef.ExploreDirectory(dir); Console.ReadLine(); } private void ExploreDirectory(DirectoryInfo dir) { DirectoryIn Read More
注:这个代码是模仿“我的电脑”实现的一个简单的网页目录浏览器1、遍历一个目录下的全部目录,要用到System.IO.DirectoryInfo 类的GetDirectories方法:DirectoryInfo dir = new DirectoryInfo(@"c:\"); foreach(DirectoryInfo dChild in dir.GetDirectories("*")){//如果用GetDirectories("ab*"),那么全部以ab开头的目录会被显示Response.Write(dChild.Name + &qu Read More