在一个驱动器文件夹中获取文件,按更新时间排序 [英] Get Files in One Drive Folder Sorted By Updated Time

查看:112
本文介绍了在一个驱动器文件夹中获取文件,按更新时间排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,允许用户从One Drive中的特定文件夹中选择应用程序备份.

I have an apps that allow user to pick an apps backups from specific folder in One Drive.

我只想显示此文件夹中按文件Updated Time(DESC)排序的10个文件,我发现了如何通过将limit=10附加到查询路径来限制文件.

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.

我正在使用Nuget中的 Live SDK 5.6.1版软件包.

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));

但是找不到如何按Updated Time进行排序.

But cannot find how to sorted by Updated Time.

推荐答案

我不确定我们使用的是REST API的相同版本,但

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

但是,根据 https://msdn.microsoft.com/zh-CN/library/hh826531.aspx ,您应该可以使用

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

这正是Clint的建议,因此,如果这对您不起作用,您可能需要考虑更新到较新的API.我可以确认排序确实可以在其中进行.

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.

这篇关于在一个驱动器文件夹中获取文件,按更新时间排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆