Home  >  Article  >  Backend Development  >  How to find files using C#?

How to find files using C#?

WBOY
WBOYforward
2023-08-25 18:54:421346browse

How to find files using C#?

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete