Files and Directories

suggest change

Get all files in a directory

var filePaths = Directory.GetFiles(path, "*", SearchOption.AllDirectories);

Directory.GetFiles returns the full paths as a string[]. DirectoryInfo.GetFiles is the API that returns FileInfo[]. On .NET Core and later, "*.*" matches only names that contain a dot; "*" matches every name.

Get files with a specific extension

var filePaths = Directory.GetFiles(path, "*.pdf", SearchOption.AllDirectories);

Returns the full paths of files in the directory, and its subdirectories, whose names match the pattern.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents