How to find the file using C#?

CsharpProgrammingServer Side Programming

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);
raja
Published on 21-Aug-2018 13:55:34
Advertisements