Nescio
Nescio

Reputation: 28443

In .Net, what is the fastest way to recursively find all files from a root directory?

I want to search a directory for all files that match a certain pattern. Surprisingly, I have not had to do this since vb6 (Dir)... I'm sure things have changed since then!

-Thanks

Upvotes: 5

Views: 470

Answers (1)

lubos hasko
lubos hasko

Reputation: 25052

use SearchOption.AllDirectories parameter:

using System.IO;

Directory.GetFiles(@"C:\", "*.mp3", SearchOption.AllDirectories);

Upvotes: 11

Related Questions