Hello friends !
Now, we will learn How to Get Files in a Directory in C#.
The GetFiles method gets a list of files in the specified directory. To get file names from the specified directory, use static method Directory.GetFiles. Lets have these files and subfolders in “C:Temp” folder.
This example shows how to get list of file names from a directory (including subdirectories). You can filter the list by specific extension.
string root = @"C:Temp";
string[] fileEntries = Directory.GetFiles(root);
foreach (string fileName in fileEntries)
{
Console.WriteLine(fileName);
}
I wish you success, please leave a comment below, we will answer all your questions.
GoodLuck !!!