C# 使用Xamarin和C将文件从Android应用程序上载到Microsoft OneDrive

C# 使用Xamarin和C将文件从Android应用程序上载到Microsoft OneDrive,c#,android,file-upload,xamarin,onedrive,C#,Android,File Upload,Xamarin,Onedrive,如何使用Xamarin for Android将文件上载到OneDrive SkyDrive 我有关于 我可以在Xamarin Studio中使用Microsoft.Live吗? 我在Visual Studio for Windows Phone应用程序中使用它: C: XAML: 是否有其他方法将文件从Android应用程序上载到其他服务器? 另外,我不能使用Visual Studio创建Android应用程序,只能使用Xamarin Studio。您可以通过创建和引用Xamarin绑定库来使

如何使用Xamarin for Android将文件上载到OneDrive SkyDrive

我有关于

我可以在Xamarin Studio中使用Microsoft.Live吗? 我在Visual Studio for Windows Phone应用程序中使用它:

C:

XAML:

是否有其他方法将文件从Android应用程序上载到其他服务器?
另外,我不能使用Visual Studio创建Android应用程序,只能使用Xamarin Studio。

您可以通过创建和引用Xamarin绑定库来使用OneDrive for Android。它允许您创建一个绑定项目,该项目基于声明性方法自动使用C包装器包装.jar库

这是官方的

下面是一个包含现有绑定库项目和示例的示例

    private void skydrive_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
    {
        if (e != null && e.Status == LiveConnectSessionStatus.Connected)
        {
            this.client = new LiveConnectClient(e.Session);
            this.GetAccountInformations();
        }
        else
        {
            this.client = null;
            InfoText.Text = e.Error != null ? e.Error.ToString() : string.Empty;
        }
    }

    private async void GetAccountInformations()
    {
        try
        {
            LiveOperationResult operationResult = await this.client.GetAsync("me");
            var jsonResult = operationResult.Result as dynamic;
            string firstName = jsonResult.first_name ?? string.Empty;
            string lastName = jsonResult.last_name ?? string.Empty;  
            InfoText.Text = "Welcome " + firstName + " " + lastName;
        }
        catch (Exception e)
        {
            InfoText.Text = e.ToString();
        }
    }

    private async void btnUpload_Click(object sender, RoutedEventArgs e)
    {
        using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (var fileStream = store.OpenFile(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                try
                {
                    LiveOperationResult res = await client.BackgroundUploadAsync("me/skydrive",
                                                                                new Uri("/shared/transfers/" + fileName, UriKind.Relative),
                                                                                OverwriteOption.Overwrite
                                                                                );
                    InfoText.Text = "File " + fileName + " uploaded";
                }
                catch (Exception ex)
                {

                }
            }
        }
    }
 <Controls:SignInButton Canvas.Left="10" Canvas.Top="351" Content="Button" 
                                           Name="skydrive" Scopes="wl.basic wl.signin wl.offline_access wl.skydrive_update" 
                                           SessionChanged="skydrive_SessionChanged" 
                                           ClientId="00000000########"/>
 <TextBlock Name="InfoText" Width="167" Height="42" Canvas.Left="192" Canvas.Top="367"></TextBlock>
 <Button Name="btnUpload" Canvas.Left="10" Canvas.Top="430" Width="166"  Click="btnUpload_Click">Upload</Button>