C#获取文件夹下的所有文件的文件名
00 String path = @"X:\xxx\xxx";
01
02 //第一种方法
03 var files = Directory.GetFiles(path, "*.txt");
04
05 foreach (var file in files)
06 Console.WriteLine(file);
07
08 //第二种方法
09 DirectoryInfo folder = new DirectoryInfo(path);
10
11 foreach (FileInfo file in folder.GetFiles("*.txt"))
12 {
13 Console.WriteLine(file.FullName);
14 }