tags:

views:

35

answers:

1

I have the following LINQ that I would like to also order by file creation date, how is this done?

taskFiles = taskDirectory.GetFiles(Id + "*.xml")
 .Where(fi => !fi.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase))
 .ToArray();
+4  A: 
taskFiles = taskDirectory.GetFiles(Id + "*.xml")
 .Where(fi => !fi.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase))
 .OrderBy(fi => fi.CreationTime)
 .ToArray();

or

var taskFiles = from taskFile in taskDirectory.GetFiles(Id + "*.xml")
                where !taskFile.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase)
                orderby taskFile.CreationTime
                select taskFile;
thekaido
Thank you very much!
JL
2nd code is much neater!
JL