Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 529
Nescio Avatar asked Sep 23 '08 05:09

Nescio


1 Answers

use SearchOption.AllDirectories parameter:

using System.IO;

Directory.GetFiles(@"C:\", "*.mp3", SearchOption.AllDirectories);
like image 121
lubos hasko Avatar answered Sep 24 '22 13:09

lubos hasko