yeeen yeeen - 4 months ago 19
C# Question

How do I search for a list of files using wildcard

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

Answer

Directory.GetFiles is your friend here:

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

or, recursively:

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