首页  >  文章  >  后端开发  >  如何使用C#查找文件?

如何使用C#查找文件?

WBOY
WBOY转载
2023-08-25 18:54:421347浏览

如何使用C#查找文件?

使用C#中的GetDirectories方法获取首先出现的子文件夹列表 −

Directory.GetDirectories

现在循环这些目录并对子文件夹重复该过程。

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);

以上是如何使用C#查找文件?的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除