·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> 遍历文件夹
//遍历文件夹 public void SearchFile(string fileDirectory) { DirectoryInfo dir = new DirectoryInfo(fileDirectory); FileSystemInfo[] f = dir.GetFileSystemInfos(); foreach (FileSystemInfo i in f) { //如果是文件夹 if (i is DirectoryInfo) { SearchFile(i.FullName); } else { FileInfo file = new FileInfo(i.FullName); StringBuilder strFile = new StringBuilder(); strFile.Append("文件名:" + file.Name + " "); strFile.Append("文件路径:" + file.FullName + " "); strFile.Append("文件大小:" + file.Length.ToString() + "<br/>"); Response.Write(strFile.ToString()); } } }