根據OneDrive core concepts(之前爲SkyDrive),您有兩個選項來列出文件,無論是在頂層目錄還是在特定文件夾中。當你找到了,你可以在GetCompleted
事件中使用
liveClient.GetAsync("me/skydrive/files");
,以及所使用folderId + "/files"
一個特定的文件夾,例如
liveClient.GetAsync(folder.Id + "/files");
榜前文件,您可以從數據中重點列出所有文件
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
}
}
不起作用:我得到一個e.Result KeyNotFoundException [「數據」] – Calanus
是的,我要求它列出根SkyDrive文件夾,即我的文件/ skydrive – Calanus
你可以遍歷你的字典,並看到它包含的鍵。 – MBen