Quantcast
Channel: SharePoint – SharePointed
Viewing all articles
Browse latest Browse all 68

Sort SPFileCollection by Created Date

$
0
0

Yes, this could be done with a CAML query, but I wanted to keep it simple.

I need to get items created in ascending order (oldest first).

My solution:

SPFileCollection items = web.GetFolder(sLawsonReports).Files;
//sort the files so we get the oldest first
List<SPFile> sortFiles = items.Cast<SPFile>().OrderBy(file => file.TimeCreated).ToList();


Viewing all articles
Browse latest Browse all 68

Trending Articles