0

我想知道将 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; 

但没有运气

4

2 回答 2

3

尝试这个:

filePaths = files.OrderBy(f => f.CreationTime).Select(x => x.FullName).ToArray(); 
于 2012-08-31T12:36:22.677 回答
0

给数组加括号();

 files.OrderBy(f => f.CreationTime).ToArray();
于 2012-08-31T12:37:27.003 回答