How to recursively list all the files in a directory in C#?

前端 未结 22 2983
长发绾君心
长发绾君心 2020-11-22 00:07

How to recursively list all the files in a directory and child directories in C#?

22条回答
  •  轮回少年
    2020-11-22 00:58

    var d = new DirectoryInfo(@"C:\logs");
    var list = d.GetFiles("*.txt").Select(m => m.Name).ToList();
    

提交回复
热议问题