从SkyDrive文件夹获取文件列表(Windows Phone)

Cal*_*nus 8 c# windows-phone-7 onedrive

有谁知道如何获取特定SkyDrive文件夹的文件列表?目前我正在使用以下代码片段来尝试获取根SkyDrive文件夹的文件:

var client = new LiveConnectClient(e.Session);

client.GetCompleted += (obj, arg) =>
     {
      ...
     }

client.GetAsync("me/skydrive");
Run Code Online (Sandbox Code Playgroud)

但它返回的是一个Result字典,其中包含大量信息但没有文件名列表!

Pat*_*ick 10

根据OneDrive核心概念(以前的SkyDrive),您可以在顶层目录或特定文件夹中列出两个文件列表.如您所知,您可以使用列出顶级文件

liveClient.GetAsync("me/skydrive/files");
Run Code Online (Sandbox Code Playgroud)

folderId + "/files"例如,对于您使用的特定文件夹

liveClient.GetAsync(folder.Id + "/files");
Run Code Online (Sandbox Code Playgroud)

在GetCompleted事件中,你可以列出从数据钥匙的所有文件

private void onFilesInformationDownloaded(object sender,
                                          LiveOperationCompletedEventArgs e) {
    if (e.Result == null) {
        // check e.Error for reason why it failed
        return;
    }
    List<object> data = (List<object>)e.Result["data"];
    foreach (IDictionary<string, object> content in data) {
        string type = (string)content["type"];
        if (type == "folder") {
            // do something with folders?
        }
        string filename = (string)content["name"];
        string fileId = (string)content["id"];
        // use fileId to download a file or list files in a folder

        // there's a few more details available in content.Keys
        // such as created_time and updated_time for those interested
    }
}
Run Code Online (Sandbox Code Playgroud)


Cal*_*nus 3

在绝望并在这里提出问题之后

事实证明,要从根 skydrive 文件夹获取文件列表,您需要使用魔术字符串 me/skydrive/files 而不仅仅是 me 或 me/skydrive