我想知道将FileSystemInfo转换为字符串数组的最有效方法是 - 我的代码如下:
string[] filePaths;
DirectoryInfo di = new DirectoryInfo(batchDirectory);
FileSystemInfo[] files = di.GetFileSystemInfos();
filePaths = files.OrderBy(f => f.CreationTime);
我试过了:
filePaths = files.OrderBy(f => f.CreationTime).ToArray;
但没有运气
答案 0 :(得分:3)
试试这个:
filePaths = files.OrderBy(f => f.CreationTime).Select(x => x.FullName).ToArray();
答案 1 :(得分:0)
将括号()添加到Array;
files.OrderBy(f => f.CreationTime).ToArray();