ListFiles

using System.IO;

public static class MyExtensions
{
	public static List<string> ListFiles(this string folderPath)
	{
		if (!Directory.Exists(folderPath)) return null;
		return (from f in Directory.GetFiles(folderPath)
					select Path.GetFileName(f)).
		ToList();
	}
}
Example:
path = @"C:\temp";
List<string> files = path.ListFiles();
if(files != null)
{
	foreach (var file in files)
	{
		Console.WriteLine(file);
	}               
}

Description

List/Get all files in a specified folder using LINQ. Doesn't include sub-directory files.

Details

Double click on the code to select all.

 

;