Question

I am in a Highschool club where we create windows store apps. I am in charge of the code that allows the user to either download files from their online onedrive storage, or upload files. So far I have successfully logged the user in and gained access to onedrive and display the users name with the following code:

 private async void LoadProfile()
        {
            bool connected = false;
            string text = "No Error:";

            try
            {
                var authClient = new LiveAuthClient();
                LiveLoginResult result = await authClient.LoginAsync(new List<string>() {"wl.signin", "wl.skydrive"});


                if (result.Status == LiveConnectSessionStatus.Connected)
                {
                    connected = true;
                    var connectClient = new LiveConnectClient(result.Session);
                    var meResult = await connectClient.GetAsync("me");
                    dynamic meData = meResult.Result;
                    Textblock_profilename.Text = meData.name;
                }
            }
            catch (LiveAuthException ex)
            {
                //Set text to corresponding error
                text = ex.ToString();
            }
            catch (LiveConnectException ex)
            {
                //Set text to corresponding error 
                text = ex.ToString();
            }


            if (text[0].ToString() != "N")
            {
                var dialog = new Windows.UI.Popups.MessageDialog(text);
                await dialog.ShowAsync();
            }

        }

I gained the code from the following MSDN tutorial: http://msdn.microsoft.com/en-us/library/dn631823.aspx

However when I try to follow the next step, downloading and uploading files, I cannot get it to work. Right now I am just trying to press a button, and have the code download a test file:

  private async void Button_downloadFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                LiveDownloadOperation operation = await connectClient.CreateBackgroundDownloadAsync("skydrive/documents/enter_path");
                var result = await operation.StartAsync();
                //DO SOMETHING WITH RESULT HERE

            }
            catch
            {
                // Handle any errors.
            }
        }

However this code throws the following errors: Error Here

This is straight from the MSDN tutorial, and can't figure out how to fix the error. My best guess is I'm missing a "using" statement, but can't figure out what I am missing. Thanks for any and all help!

Était-ce utile?

La solution

Make sure you're updated to use the Live SDK 5.6 binary. Be sure to let us know if you have any other problems with OneDrive integration!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top