Skip to content

Developers can enumerate directories and files using globbing patterns #21362

Open
@khellang

Description

@khellang

I'd like to start a discussion on including a file system globbing API in .NET (Core). If you look at implementations mentioned on Wikipedia, every "mainstream platform" has an entry, but not .NET.

There's quite a few (more or less) successful implementations around (see below), some even from Microsoft, but I think something as fundamental as this, should ship with the framework.

There's already partial globbing support using the following methods

  • Directory.GetFiles
  • Directory.EnumerateFiles
  • Directory.GetFileSystemEntries
  • Directory.EnumerateFileSystemEntries
  • Directory.GetDirectories
  • Directory.EnumerateDirectories

They all have a searchPattern argument, but it lacks support for recursive globs (** aka. "globstar"), brace expansion etc. This can be achieved using the SearchOption argument, but the API is hard to use when you want to support (often user-defined) recursive patterns like /src/**/*.csproj.

I'd ❤️ to hear people's opinions here...

  • Is it worth including in the framework?
  • Should new APIs be introduced, or can we "level up" the existing searchPattern in the methods mentioned above (without it being a breaking change)?

Examples

And tons of other implementations...

Metadata

Metadata

Labels

Cost:MWork that requires one engineer up to 2 weeksPriority:2Work that is important, but not critical for the releaseTeam:LibrariesUser StoryA single user-facing feature. Can be grouped under an epic.api-needs-workAPI needs work before it is approved, it is NOT ready for implementationarea-System.IO

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions