Theo OneDrive core concepts (trước đây là SkyDrive), bạn có hai tùy chọn để liệt kê tệp, trong thư mục trên cùng hoặc một thư mục cụ thể. Như bạn phát hiện ra, bạn có thể liệt kê các tập tin đầu sử dụng
liveClient.GetAsync("me/skydrive/files");
và cho một thư mục cụ thể mà bạn sử dụng folderId + "/files"
, ví dụ
liveClient.GetAsync(folder.Id + "/files");
trong trường hợp GetCompleted
bạn có thể liệt kê tất cả các file từ chìa khóa dữ liệu
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
}
}
Không làm việc: Tôi nhận được một KeyNotFoundException cho e.Result [ "dữ liệu"] – Calanus
Vâng, tôi đang hỏi nó liệt kê các file trong thư mục gốc SkyDrive thư mục tức là tôi/skydrive – Calanus
bạn có thể lặp qua từ điển của mình và xem các khóa có trong đó không. – MBen