//第一种方法 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
时间: 2024-11-05 23:23:21