Thursday, February 09, 2006

Multiple search patterns with DirectoryInfo.GetFiles()

Another visit to Google today showed various requests about how to specify more than one pattern to search for when grabbing the files from a directory, so for example, get all the .mp3 and .wma files in one call.

As far as I can see, you can only specify one pattern at a time (unless there's something new in 2.0 that I've missed) so I thought this was a good candidate for a simple wrapper. The code below should be fairly easy to modify if you have any specific requirements in your situation.

No comments: