OneDrive / onedrive-sdk-csharp

OneDrive SDK for C#! https://dev.onedrive.com
Other
295 stars 145 forks source link

Enumerate the contents of a shared folder with C# SDK #214

Closed jaycdave88 closed 7 years ago

jaycdave88 commented 7 years ago

I came across this article - https://dev.onedrive.com/misc/working-with-links.htm#enumerate-the-contents-of-a-shared-folder and after reading this it seems like this is what I need to do in order to return a list a child elements on a Shared folder. However, I am trying to find an example of how to do this with the OneDrive C# SDK...

Currently my code lines are as follows:

var remoteItemDriveId = folder.RemoteItem.ParentReference.DriveId; var folderTest = await oneDriveClient.Drive.Items[remoteItemDriveId].Request().GetAsync();

However this is just throwing some thread has exited with code 0 error. Is this the correct way to pull back the collection and find the child elements?

daboxu commented 7 years ago

@jaycdave88 hi, try

var driveId = folder.RemoteItem.ParentReference.DriveId;
var folderId = folder.RemoteItem.id;
oneDriveClient.Drives[driveId].Items[folderId].Children.Request().GetAsync();

to get the children of the shared folder, it seems you passed the driveId to item which is not aligned with the doc saying:

GET /drives/{drive-id}/items/{item-id}/children