I am looking for a built-in functionality in .NET to query folders with relative paths and wildcards, similar to Powershell’s dir command (also known as ls). As far as I remember, Powershell returns an array of DirectoryInfo and FileInfo .NET objects, which can later be used for processing. Example input:
..\bin\Release\XmlConfig\*.xml
would translate into several FileInfo‘s of XML files.
Is there anything like that in .NET?
System.IO.Directoryis the static class that provides that functionality.For instance your example would be:
A more complex example would be: (note this isn’t really tested very thoroughly, for instance ending a string with
\would cause it to error)