Use the GetDirectories method in C# to get the list of subfolders that appear first −
Directory.GetDirectories
Now loop through these directories and repeat the process for the subfolders.
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);
The above is the detailed content of How to find files using C#?. For more information, please follow other related articles on the PHP Chinese website!