C#遍历一个文件夹下的所有文件夹

 
  1. string thePath = "../../Upload/Star/";
  2.         thePath = Server.MapPath(thePath);//得到文件绝对路径
  3.         System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(thePath);
  4.         System.IO.DirectoryInfo[] ds = d.GetDirectories("*.*", System.IO.SearchOption.TopDirectoryOnly);
  5.         foreach (System.IO.DirectoryInfo var in ds)
  6.         {
  7.             //路径全称 
  8.             Response.Write(var.FullName + "<br/>");//遍历文件夹下面的文件夹
  9.             //仅文件名称 
  10.             Response.Write(var.Name + "<br/>");
  11.         }
posted on 2008-11-12 15:54  叮叮猫的编程世界  阅读(152)  评论(0编辑  收藏  举报