我有以下LINQ,我想按文件创建日期排序,这是怎么做的?
taskFiles = taskDirectory.GetFiles(Id + "*.xml")
.Where(fi => !fi.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase))
.ToArray();
答案 0 :(得分:4)
taskFiles = taskDirectory.GetFiles(Id + "*.xml")
.Where(fi => !fi.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase))
.OrderBy(fi => fi.CreationTime)
.ToArray();
或强>
var taskFiles = from taskFile in taskDirectory.GetFiles(Id + "*.xml")
where !taskFile.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase)
orderby taskFile.CreationTime
select taskFile;