C#从获取指定目录下的所有文件列表
using System; using System.IO; class MainClass { static void Main(string[] args) { DirectoryInfo dir = new DirectoryInfo("c:\\"); FileInfo[] files = dir.GetFiles("c:\\a.txt"); foreach (FileInfo file in files) { Console.Write("Name: " + file.Name + " "); Console.WriteLine("Size: " + file.Length.ToString()); } } }