You can use the Directory.GetFiles method to list all files in a folder:
string[] files = Directory.GetFiles(@"c:\files\folder1\",
"*.*",
SearchOption.AllDirectories);
foreach (var file in files)
{
Console.WriteLine(file);
}
Note that the SearchOption
parameter can be used to control whether the search is recursive (SearchOption.AllDirectories
) or not (SearchOption.TopDirectoryOnly
).