I want to find all excel files within a directory structure using recursion. The problem is, the search pattern used in Directory.GetFiles only allows a single extension at a t
I think the second alternative is more efficient. Loop through every file with the following pattern: .xl, then narrow the list looking for specific endings.
Something like:
foreach (String f in Directory.GetFiles(path, "*.xl*", SearchOption.AllDirectories))
{
if (HasSomeExcelExtension(f))
files .Add(f);
}
You could use the EndsWith method to check "f" against each extension, or extract the extension using the Path.GetExtension method and look it up in a hashtable containing the desired extensions.
just my $.02 hth