日期:2014-05-17 浏览次数:20764 次
string[] fileList = new DirectoryInfo(@"C:\Users\mypc\Desktop\examples")
.EnumerateFileSystemInfos("*").Select(item => item.Name).ToArray();
//输出:
fileList.ToList().ForEach(item => Console.WriteLine(item));
FileSystemInfo[] fsi = new DirectoryInfo(@"C:\Users\mypc\Desktop\examples").GetFileSystemInfos();
string[] fileList = new string[fsi.Length];
for (int i = 0; i < fileList.Length; i++)
{
fileList[i] = fsi[i].Name;
}