c#获取文件夹中指定类型的文件

//第一种方法
var files = Directory.GetFiles(path, "*.txt");
             
foreach (var file in files)
    Console.WriteLine(file);
 
//第二种方法
DirectoryInfo folder = new DirectoryInfo(path);
            
foreach (FileInfo file in folder.GetFiles("*.txt"))
{
    Console.WriteLine(file.FullName);
}

  

文章来自:https://www.cnblogs.com/dushaojun/p/8523629.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3