C#获取文件夹下的所有文件的文件名
String path =
@"X:\xxx\xxx"
;
//第一种方法
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);
}