问题
I have an apps that allow user to pick an apps backups from specific folder in One Drive
.
I want to show only 10 files from this folder sorted by file Updated Time
(DESC), I have found how to limit the files by appending limit=10
to query path.
I'm using Live SDK ver 5.6.1 package from Nuget
.
LiveConnectClient client = new LiveConnectClient(session);
var result = await client.GetAsync(string.Format("{0}/files?limit=10", folderId));
But cannot find how to sorted by Updated Time
.
回答1:
I'm not sure we are using the same version of the REST API, but the one documented at http://onedrive.github.io/index.htm (using dollar notation for the parameters) uses $orderby . For example,
https://api.onedrive.com/v1.0/drive/items/[FOLDER ID]/children?$orderby=lastModifiedDateTime%20desc
However, if you are stuck on the older Live SDK, according to the documentation at https://msdn.microsoft.com/en-us/library/hh826531.aspx you should be able to use
FOLDER_ID/files?sort_by=updated&sort_order=descending
That's exactly what Clint suggested, so if that doesn't work for you, you might want to consider updating to the newer API. I can confirm that sorting definitely works there.
回答2:
I haven't tried this but...
var result = await client.GetAsync(string.Format("{0}/files?limit=10&sort_by=updated", folderId));
来源:https://stackoverflow.com/questions/29485895/get-files-in-one-drive-folder-sorted-by-updated-time