C# Get file names in directory (loop through directory and get filenames)

This code example demonstrates Csharp programming techniques and best practices.

string[] files =
                Directory.GetFiles("D:\\M2Images", "*.jpg", SearchOption.AllDirectories);

Language: Csharp
Original Source: BlogEngine.NET Migration
Code Lines: 6

Gather a set of filenames from a directory and it's sub folders. 

 

This returns an array of absolute paths to all of the files in the directory specified in the first argument of GetFiles. 

C# Get file names in directory (loop through directory and get filenames)

gather filenames from a directory and it's sub folders.  string[] files =