String path = @"X:\xxx\xxx";
//第一种方法
string[] files = Directory.GetFiles(path, "*.txt");
foreach (string file in files)
{
Console.WriteLine(file);
}
//第二种方法
DirectoryInfo folder = new DirectoryInfo(path);
foreach (FileInfo file in folder.GetFiles("*.txt"))
{
Console.WriteLine(file.FullName);
}
亲爱的:若该文章解决了您的问题,可否收藏+评论+分享呢?
文章评论 本文章有个评论