Here is source code of the C# Program to Search Directories and List Files. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
* C# Program to Search Directories and List Files
static void Main()
string Dirfile = Directory.GetFiles("C:\\sri\\","*.*",SearchOption.AllDirectories);
foreach (string file in Dirfile)
Here is the output of the C# Program:
The List of Files in the Directory are : C:\sri\message.txt C:\sri\srip.txt C:\sri\test.txt
Sanfoundry Global Education & Learning Series – 1000 C# Programs.