//遍历文件夹 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()); } } }
新闻热点
疑难解答