How to read File names recursively from subfolder using LINQ

前端 未结 5 1184
鱼传尺愫
鱼传尺愫 2021-01-13 09:36

How to read file name with dll extension from a directory and from its subfolders recursively using LINQ or LAMBDA expression.

Now i\'m using Nested for

5条回答
  •  逝去的感伤
    2021-01-13 10:09

    IEnumerable filenames = Directory.GetFiles(searchDirectory, "*.dll",
                                                       SearchOption.AllDirectories)
                                             .Select(s => Path.GetFileName(s));
    

    Directory.GetFiles() returns the full path of files that match the specified search pattern in the specified directory. Select projects each element of fullpath sequence into a new form, only the filename.

提交回复
热议问题