How to find the file using C#?



Use the GetDirectories in C# to get a list of sub-folder that appears first −

Directory.GetDirectories

Now loop through those directories and repeat the process for the sub folder.

string path = @"d:/New/Myfile";
string[] myDir = Directory.GetDirectories(path, "xml", SearchOption.AllDirectories);
Console.WriteLine(myDir.Length.ToString());
foreach (string res in myDir)
Console.WriteLine(res);
Updated on: 2020-06-22T10:53:53+05:30

146 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements