|||
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);
}
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2025-1-6 16:48
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社