public static List<string> readDir(string path)
{
List<string> files = new List<string>();
if(!Directory.Exists(path))
{
return null;
}
string[] dirs = Directory.GetDirectories(path);
if(dirs.Length>0)
{
for (int i = 0; i < dirs.Length; i++)
{
files.AddRange(readDir(dirs[i]));
}
}files.AddRange(Directory.GetFiles(path));
return files;
}
未经允许不得转载:开心乐窝-乐在其中 » C#递归遍历文件夹下所有文件