I am trying to use the Directory.GetFiles()
method to retrieve a list of files of multiple types, such as mp3
's and jpg
's. I have tried both of the following with no luck:
Directory.GetFiles("C:\\path", "*.mp3|*.jpg", SearchOption.AllDirectories);
Directory.GetFiles("C:\\path", "*.mp3;*.jpg", SearchOption.AllDirectories);
Is there a way to do this in one call?
Nope. Try the following:
Taken from: http://blogs.msdn.com/markda/archive/2006/04/20/580075.aspx
Just found an another way to do it. Still not one operation, but throwing it out to see what other people think about it.
Or you can just convert the string of extensions to String^
Let
Then
or
There is also a descent solution which seems not to have any memory or performance overhead and be quite elegant: