Possible to specify directory path with a wildcard?

后端 未结 1 900
北荒
北荒 2020-12-11 15:56

I have the following piece of code:

foreach (string file in Directory.GetFiles(sourcePath))
{
    // whatever
}

That gets files from a spec

相关标签:
1条回答
  • 2020-12-11 16:33

    You have an overload for this which allows you to specify a search pattern or if you need to specify search options there's another overload:

    foreach (string directory in Directory.GetDirectories(sourcePath, "di*"))
    {
        // whatever
    }
    
    0 讨论(0)
提交回复
热议问题