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 t
I can't use .Where
method because I'm programming in .NET Framework 2.0 (Linq is only supported in .NET Framework 3.5+).
Code below is not case sensitive (so .CaB
or .cab
will be listed too).
string[] ext = new string[2] { "*.CAB", "*.MSU" };
foreach (string found in ext)
{
string[] extracted = Directory.GetFiles("C:\\test", found, System.IO.SearchOption.AllDirectories);
foreach (string file in extracted)
{
Console.WriteLine(file);
}
}