How to collect all files in a Folder and its Subfolders that match a string

后端 未结 6 1016
野性不改
野性不改 2020-12-16 12:05

In C# how can I search through a Folder and its Subfolders to find files that match a string value. My string value could be \"ABC123\" and a matching file might be ABC123_

6条回答
  •  时光说笑
    2020-12-16 12:54

    You're looking for the Directory.GetFiles method:

    Directory.GetFiles(path, "*" + search + "*", SearchOption.AllDirectories)
    

提交回复
热议问题