asp.net遍历文件夹和文件

DirectoryInfo dir = new DirectoryInfo(Path);
foreach (DirectoryInfo df
in dir.GetDirectories())
{
if (df.ToString().Length != 18)
{
StreamWriter sw
= new StreamWriter(@"Paht",true,Encoding.UTF8);
sw.WriteLine(Path
+":"+df);
sw.
Close();
}
DirectoryInfo fdir
= new DirectoryInfo(Path+df+@"\");
// int i = 0;
if (!Directory.Exists(fdir.ToString()))
{
StreamWriter sw
= new StreamWriter(@"Path", true, Encoding.UTF8);
sw.WriteLine(Path
+ ":" + df);
sw.
Close();
}
foreach (FileInfo dChild
in fdir.GetFiles("*.swf"))
{
// i++;
}
}

原文地址:https://www.cnblogs.com/_fyz/p/1869279.html