先通过DirectoryInfo打开指定的目录,然后通过GetFiles()方法读取文件夹下的所有文件
DirectoryInfo di = new DirectoryInfo(@"C:\mydir"); Console.WriteLine("Directory: {0}", di.FullName); foreach (FileInfo file in di.GetFiles()) { Console.WriteLine("File: {0}", file.Name); }
先通过DirectoryInfo打开指定的目录,然后通过GetFiles()方法读取文件夹下的所有文件
DirectoryInfo di = new DirectoryInfo(@"C:\mydir"); Console.WriteLine("Directory: {0}", di.FullName); foreach (FileInfo file in di.GetFiles()) { Console.WriteLine("File: {0}", file.Name); }