How do i find the folder id of a Skydrive folder using the folder name. Or Is it possible to delete a folder in Skydrive without its folder id.

Am using Windows Phone 8 - LiveConnectClient

-Thanks

有帮助吗?

解决方案

I don't think there is a search API but you can do it yourself.

This code is for 5.2 SDK but you get the idea. List the folders in the root folder. If needed list the subfolders till you find the directory.

This is to list the root:

clientFolder.GetAsync("me/skydrive/files");

And to get the ids:

        foreach (IDictionary<string, object> album in data)
        {
            SkydriveAlbum albumItem = new SkydriveAlbum();
            albumItem.ID = (string)album["id"];
        }

Full code:

/// <summary>
/// Gets the root dirs from SkyDrive
/// </summary>
public void ListSkyDriveRootAlbums()
{
    List<SkydriveAlbum> albums = new List<SkydriveAlbum>();
    LiveConnectClient clientFolder = new LiveConnectClient(App.Session);
    clientFolder.GetCompleted += (sender, e) =>
    {
        if (e.Error == null)
        {
            List<object> data = (List<object>)e.Result["data"];
            foreach (IDictionary<string, object> album in data)
            {
                SkydriveAlbum albumItem = new SkydriveAlbum();
                albumItem.Title = (string)album["name"];
                albumItem.Description = (string)album["description"];
                albumItem.ID = (string)album["id"];
                albums.Add(albumItem);
            }

            if (ListAlbumsCompleted != null)
            {
                ListAlbumsCompleted(albums.ToArray(), e.Error);
            }
        }
        else if (ListAlbumsCompleted != null)
        {
            ListAlbumsCompleted(null, e.Error);
        }
    };

    clientFolder.GetAsync("me/skydrive/files");
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top