How do I search for a list of files using wildcard

yeeen picture yeeen · Oct 18, 2009 · Viewed 38.7k times · Source

How do I use wildcards in C# to list down files contained in a selected folder?

Answer

Joey picture Joey · Oct 18, 2009

Directory.GetFiles is your friend here:

Directory.GetFiles(@"C:\Users\Me\Documents", "*.docx");

or, recursively:

Directory.GetFiles(
    @"C:\Users\Me\Documents",
    "*.docx",
    SearchOption.AllDirectories);