var files = Directory.GetFiles("C:\\path", "*.*", SearchOption.AllDirectories)
.Where(s => s.EndsWith(".mp3") || s.EndsWith(".jpg"));
edit: Please read the comments. The improvement that Paul Farry suggests, and the memory/performance issue that Christian.K points out are both very important.
s.ToLower().Endswith...
– Stormenet May 5 '10 at 9:35s.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase)
– Paul Farry May 31 '10 at 22:58Directory.GetFiles
withDirectory.EnumerateFiles
,msdn.microsoft.com/en-us/library/dd383571.aspx , which will avoid the memory issues that @Christian.K mentions. – Jim Mischel Dec 2 '11 at 22:58