我搜索了两天,试图在VB.net中找到如何做到这一点的答案。我为C#找到了多个答案,但语法不正确,我无法固定下来,直到我找到了完美的答案。
'Newest first, oldest last
Dim filesByCreateDate = New DirectoryInfo("Folder to Search").GetFiles().OrderByDescending(Function(fi) fi.CreationTime).Take(10).ToArray
'Newest File
Dim newestFile = New DirectoryInfo("Folder to Search").GetFiles().OrderByDescending(Function(fi) fi.CreationTime).First
'Oldest File
Dim oldestFile = New DirectoryInfo("Folder to Search").GetFiles().OrderBy(Function(fi) fi.CreationTime).First