×
Namespaces

Variants
Actions
(Difference between revisions)

SkyDrive - How to upload content on Windows Phone

From Nokia Developer Wiki
Jump to: navigation, search
galazzo (Talk | contribs)
m (Galazzo - - Uploading a file)
kiran10182 (Talk | contribs)
m (Kiran10182 - Project migration task)
 
(25 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[Category:Multimedia]][[Category:Networking]][[Category:Windows Phone]][[Category:Code Examples]][[Category:Code Snippet]]
+
[[Category:Web Services on Windows Phone]][[Category:Files/Data on Windows Phone]][[Category:XAML]][[Category:Code Examples]][[Category:Tutorial]][[Category:Windows Phone 8]][[Category:Windows Phone 7.5]]
 +
{{Abstract|This article explains how to upload files to SkyDrive cloud storage from Windows Phone, using [http://msdn.microsoft.com/en-us/live//default Live Connect]}}
 
{{ArticleMetaData <!-- v1.2 -->
 
{{ArticleMetaData <!-- v1.2 -->
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
+
|sourcecode= [[Media:WpFFT.zip|Noise Reduction]] (uses this code)
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|devices= Nokia Lumia 800
+
|devices= Nokia Lumia 800, Nokia Lumia 820
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 
|platform= Windows Phone
 
|platform= Windows Phone
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->  
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
+
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 
|keywords= SkyDrive
 
|keywords= SkyDrive
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|translated-by= <!-- [[User:XXXX]] -->
 
|translated-by= <!-- [[User:XXXX]] -->
|translated-from-title= <!-- Title only -->  
+
|translated-from-title= <!-- Title only -->
 
|translated-from-id= <!-- Id of translated revision -->
 
|translated-from-id= <!-- Id of translated revision -->
|review-by=<!-- After re-review: [[User:username]] -->
+
|review-by= <!-- After re-review: [[User:username]] -->
 
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 
|update-by= <!-- After significant update: [[User:username]]-->
 
|update-by= <!-- After significant update: [[User:username]]-->
Line 23: Line 24:
 
}}
 
}}
  
[[File:Skydrive-logo-200.png]] is a Microsoft service that allow you to store files into a cloud in order to be automatically available from your phone and computers. You can share large files and photos or documents with your friends or collegues.  
+
{{SeeAlso|
Although the service is available for many platforms such as Windows, Mac, iOS, Android all you need to access to your content is a web browser.<br />
+
* [[http://msdn.microsoft.com/en-us/library/live/hh826521.aspx SkyDrive API (Live Connect)]]
This article is focused on the most interesting feature, the mobile access.
+
* [[http://msdn.microsoft.com/en-us/library/live/microsoft.live.liveconnectclient.backgroundupload BackgroundUploadAsync]]
 +
* [http://msdn.microsoft.com/en-us/library/live/hh243646.aspx Scopes and permissions]
 +
}}
  
== Live Connect ==
+
== Introduction ==
[http://msdn.microsoft.com/en-us/live//default Live Connect] provides developers a set of controls and APIs that enable applications to integrate sign in with the user’s Microsoft account and enable users to access information from SkyDrive, Hotmail, and Messenger. At time of writing these APIs are not included by default on Windows Phone SDK.
+
SkyDrive is a Microsoft cloud service that allows you to access your files and documents on all your phones and computers, and to share them easily with your friends and colleagues. The service is available as an extension to the native file browser on many platforms (e.g. Windows, Mac, iOS, Android) and is also accessible from most web browsers. In addition, it is possible to access the service directly in your apps using the set of controls and APIs in the [http://msdn.microsoft.com/en-us/live//default Live Connect] SDK (these allow developers to integrate with SkyDrive, Hotmail, and Messenger).  
  
Before start developing
+
[[File:Skydrive-logo-200.png|none]]
  
 +
This article explains how to obtain the LiveConnect SDK, add the APIs to your project, login to the service, and upload a file. The code works on Windows Phone 8. To use it on Windows Phone 7.x you need some extra jobs described [http://blogs.msdn.com/b/bclteam/archive/2012/10/22/using-async-await-without-net-framework-4-5.aspx here].
 +
 +
== Prerequisites ==
 +
At the time of writing this article, the LiveConnect APIs are not included by default on the Windows Phone SDK.
 +
 +
Before you start developing:
 
* Download lastest [https://dev.windowsphone.com/en-us/downloadsdk Windows Phone SDK]
 
* Download lastest [https://dev.windowsphone.com/en-us/downloadsdk Windows Phone SDK]
 
* Download [http://msdn.microsoft.com/it-IT/live/ff621310 Live Connect SDK]
 
* Download [http://msdn.microsoft.com/it-IT/live/ff621310 Live Connect SDK]
 +
  
 
== Creating the application ==
 
== Creating the application ==
Create a new HelloWorldPhone Windows Phone application in Microsoft Visual Studio 2010 Express for Windows Phone using the Visual C# -> Silverlight for Windows Phone -> Windows Phone Application project template and name it ''SkyDrive''
+
Create a new HelloWorldPhone Windows Phone application in Microsoft Visual Studio 2010 Express for Windows Phone using the '''Visual C# -> Silverlight for Windows Phone -> Windows Phone Application project''' template and name it ''SkyDrive'':
[[File:SkyDrive-step-000.png]]<br />
+
:[[File:SkyDrive-step-000.png|none|thumb|900px]]
Choose last OS version<br />
+
 
[[File:SkyDrive-step-001.png]]<br />
+
Choose last OS version
Bring up the Add Reference dialog and go to the .Net tab. Scroll down to find the Microsoft.Live and Microsoft.Live.Controls assemblies. Add them to your project.<br />
+
:[[File:SkyDrive-step-001.png|none|400px]]
[[File:SkyDrive-step-002.png]]<br />
+
 
Open MainPage.xaml in the designer. Bring the Toolbox in view and right-click to select Choose Items… Under Windows Phone Components tab, find the SignInButton control in the Microsoft.Live.Control namespace and add to your toolbox (You only need to do this once).<br />
+
Bring up the '''Add Reference''' dialog and go to the .Net tab. Scroll down and add the {{Icode|Microsoft.Live}} and {{Icode|Microsoft.Live.Controls}} assemblies to your project.
[[File:SkyDrive-step-003.png]]<br />
+
:[[File:SkyDrive-step-002.png|none|900px]]
If everything is well installed you should see the SignInButton control in your toolbox. Drag it onto your designer surface.<br />
+
 
[[File:SkyDrive-step-004.png]]<br />
+
Open '''MainPage.xaml''' in the designer. Bring the Toolbox in view and right-click to select Choose Items… Under Windows Phone Components tab, find the SignInButton control in the Microsoft.Live.Control namespace and add to your toolbox (You only need to do this once).
 +
:[[File:SkyDrive-step-003.png|none|900px]]
 +
 
 +
If everything is well installed you should see the {{Icode|SignInButton}} control in your toolbox. Drag it onto your designer surface.
 +
:[[File:SkyDrive-step-004.png|none]]
  
 
=== Scopes and permissions ===
 
=== Scopes and permissions ===
Before your app makes requests of the Live Connect APIs to work with Live Connect info, in most cases you must get permission from the user to access that info or to create new objects on behalf of the user. In the Live Connect APIs, this permission is called a scope. Each scope grants a different permission level.<br />
+
Before your app makes requests of the Live Connect APIs to work with Live Connect info, in most cases you must get permission from the user to access that info or to create new objects on behalf of the user. In the Live Connect APIs, this permission is called a scope. Each scope grants a different permission level.
There are three types of scopes:
+
  
 +
There are three types of scopes:
 
* Core scopes are central to the Live Connect APIs and involve users' core profile and contact data.
 
* Core scopes are central to the Live Connect APIs and involve users' core profile and contact data.
 
* Extended scopes allow you to work with users' extended profile and contact data.
 
* Extended scopes allow you to work with users' extended profile and contact data.
Line 77: Line 91:
 
|}
 
|}
  
Into .xaml file your code should look like that:
+
'''Into.xaml''' file your code should look like that:
 
<code xml>
 
<code xml>
 
<my:SignInButton Content="Button" Name="skydrive" Scopes="wl.basic wl.signin wl.offline_access wl.skydrive_update" SessionChanged="skydrive_SessionChanged"  />
 
<my:SignInButton Content="Button" Name="skydrive" Scopes="wl.basic wl.signin wl.offline_access wl.skydrive_update" SessionChanged="skydrive_SessionChanged"  />
Line 84: Line 98:
 
=== ClientId ===
 
=== ClientId ===
 
Now we need to connect our application to Live Connect. Go to the [https://manage.dev.live.com/ application management site] and click the [https://manage.dev.live.com/AddApplication.aspx Create Application]. Create an application and provide a name for it.<br />
 
Now we need to connect our application to Live Connect. Go to the [https://manage.dev.live.com/ application management site] and click the [https://manage.dev.live.com/AddApplication.aspx Create Application]. Create an application and provide a name for it.<br />
[[File:SkyDrive-step-005.png]]<br />
+
:[[File:SkyDrive-step-005.png|none|frame]]
If everything goes well you will be provided with a ClientID and a Client secret code<br />
+
If everything goes well you will be provided with a {{Icode|ClientID}} and a Client secret code:
[[File:SkyDrive-step-006.png]]<br />
+
:[[File:SkyDrive-step-006.png|none|frame]]
Now let's add the ClientID to our SignInButton code<br />
+
 
 +
Now let's add the {{Icode|ClientID}} to our {{Icode|SignInButton}} code:
 
<code xml>
 
<code xml>
<my:SignInButton Content="Button" Name="skydrive" ClientId="00000000440xxxxx" Scopes="wl.basic wl.signin wl.offline_access wl.skydrive_update" SessionChanged="skydrive_SessionChanged"  />
+
<my:SignInButton Content="Button" Name="skydrive" ClientId="00000000440xxxxx" Scopes="wl.basic wl.signin wl.offline_access wl.skydrive_update" Branding="Skydrive" TextType="SignIn" SessionChanged="skydrive_SessionChanged"  />
 
</code>
 
</code>
  
Line 102: Line 117:
 
</code>
 
</code>
  
=== SkyDrive LogIn session management ===
+
=== SkyDrive Login session management ===
 
<code csharp>
 
<code csharp>
private void skydrive_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
+
private void skydrive_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
 
{
 
{
             if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
+
 
 +
             if (e != null && e.Status == LiveConnectSessionStatus.Connected)
 
             {
 
             {
                 client = new LiveConnectClient(e.Session);
+
                 this.client = new LiveConnectClient(e.Session);              
                 MessageBar.Text = "Signed in.";
+
                 this.GetAccountInformations();
                client.GetCompleted    += new EventHandler<LiveOperationCompletedEventArgs>(signin_GetCompleted);
+
                client.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(uploadClient_UploadCompleted);
+
                client.GetAsync("me", null);
+
 
             }
 
             }
 
             else
 
             else
 
             {
 
             {
                 MessageBar.Text = "Not signed in:" + e.Status.ToString();
+
                 this.client = null;
                client = null;
+
                InfoText.Text = e.Error != null ? e.Error.ToString() : string.Empty;              
             }  
+
             }
 +
           
 
}
 
}
  
void signin_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
+
private async void GetAccountInformations()
{
+
{
             if (e.Error == null)
+
             try
 
             {
 
             {
                 MessageBar.Text = "Hello, signed-in user!";
+
                 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;
 
             }
 
             }
             else
+
             catch (Exception e)
 
             {
 
             {
                 MessageBar.Text = "Error calling API: " + e.Error.ToString();
+
                 InfoText.Text = e.ToString();
 
             }
 
             }
}
+
}
</code><br />
+
</code>
Here the login screenshot<br />
+
 
[[File:SkyDrive-step-010.png]]<br />
+
Here the login screenshot
 +
[[File:SkyDrive-step-010.png|none|thumb|800px|Login screenshot]]
  
 
=== Uploading a file ===
 
=== Uploading a file ===
 +
First we create a Demo file to upload. Here an example of a bynary file:
 
<code csharp>
 
<code csharp>
private void uploadButton_Click(object sender, EventArgs e)
+
private string fileName = "sample.dat";
{
+
private IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
            if (client != null)
+
            {
+
                MessageBar.Text = "Uploading to SkyDrive";
+
                IsolatedStorageFileStream fileStream = null;
+
  
                try
+
private void CreateFileIntoIsolatedStorage()
                {
+
{          
                    using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
+
            if (isf.FileExists(fileName))
                    {
+
                        fileStream = store.OpenFile(fileName, FileMode.Open, FileAccess.Read);
+
                    }
+
                }
+
                catch (Exception ex)
+
                {
+
                    MessageBox.Show(ex.Message);
+
                }               
+
                client.UploadAsync("me/SkyDrive", strSaveName, fileStream, OverwriteOption.Overwrite);
+
            }
+
            else
+
 
             {
 
             {
                 MessageBox.Show("You must be signed for SkyDrive");
+
                 isf.DeleteFile(fileName);
 
             }
 
             }
 +
 +
            IsolatedStorageFileStream isfStream =  new IsolatedStorageFileStream(fileName,  FileMode.Create, IsolatedStorageFile.GetUserStoreForApplication());
 +
                       
 +
            byte[] output = new byte[25];
 +
 +
            for (int i = 0; i < 25; i++)
 +
            {             
 +
                output[i] = (byte)(i);               
 +
            }
 +
 +
            isfStream.Write(output, 0, output.Length);
 +
 +
            isfStream.Close();
 
}
 
}
 +
</code>
  
void uploadClient_UploadCompleted(object sender, LiveOperationCompletedEventArgs e)
+
In this example we call the method from constructor, but of course is possible to create the file when and where needed.
 +
<code csharp>
 +
public MainPage()
 
{
 
{
             if (e.Error == null)
+
             InitializeComponent();
 +
          CreateFileIntoIsolatedStorage();
 +
}
 +
</code>
 +
 
 +
Now we can upload the file
 +
<code csharp>
 +
private async void btnUpload_Click(object sender, RoutedEventArgs e)
 +
{                   
 +
      using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
 +
      {
 +
            using (var fileStream = store.OpenFile(strSaveName, FileMode.Open, FileAccess.Read, FileShare.Read))
 
             {
 
             {
                MessageBar.Text = "File uploaded with success!";
+
                    try
                MessageBox.Show("File uploaded with success!");
+
                    {                     
            }
+
                        LiveOperationResult res = await client.BackgroundUploadAsync("me/skydrive",
            else
+
                                                                                    new Uri("/shared/transfers/"+fileName, UriKind.Relative),
            {
+
                                                                                    OverwriteOption.Overwrite
                MessageBar.Text = "File uploading failed!";
+
                                                                                    );
                MessageBox.Show("File uploading failed!");
+
                      InfoText.Text = "File "+fileName+" uploaded";
            }
+
                    }  catch (Exception ex) {
}
+
 
 +
                    }
 +
            }
 +
      }
 +
}
 
</code>
 
</code>
 +
=== BackgroundUploadAsync ===
 +
'''Parameters'''
 +
* path
 +
: Type: {{Icode|String}}
 +
The folder ID of the folder in SkyDrive to upload the file to, for example "folder.8c8ce076ca27823f.8C8CE076CA27823F!142"
 +
 +
* uploadLocation
 +
: Type: {{Icode|Uri}}
 +
The unique isolated storage path to where the file is to be uploaded from, for example "/shared/transfers/myFile2.txt"
 +
 +
* option
 +
: Type: {{Icode|OverwriteOption}}
 +
Specifies whether the file that's being uploaded to SkyDrive should overwrite an existing file with the same file name in that location.
  
 
== Code sample ==
 
== Code sample ==
* [http://projects.developer.nokia.com/WpFFT/browser/examples Noise Reduction]
+
* [[Media:WpFFT.zip|Noise Reduction]]
 +
 
 +
== Links ==
 +
* [http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202955%28v=vs.105%29.aspx limitations]

Latest revision as of 22:05, 9 October 2013

This article explains how to upload files to SkyDrive cloud storage from Windows Phone, using Live Connect

WP Metro Icon File.png
WP Metro Icon Web.png
SignpostIcon XAML 40.png
WP Metro Icon WP8.png
SignpostIcon WP7 70px.png
Article Metadata
Code Example
Source file: Noise Reduction (uses this code)
Tested with
Devices(s): Nokia Lumia 800, Nokia Lumia 820
Compatibility
Platform(s): Windows Phone
Windows Phone 8
Windows Phone 7.5
Article
Keywords: SkyDrive
Created: galazzo (06 Sep 2012)
Last edited: kiran10182 (09 Oct 2013)

Contents

[edit] Introduction

SkyDrive is a Microsoft cloud service that allows you to access your files and documents on all your phones and computers, and to share them easily with your friends and colleagues. The service is available as an extension to the native file browser on many platforms (e.g. Windows, Mac, iOS, Android) and is also accessible from most web browsers. In addition, it is possible to access the service directly in your apps using the set of controls and APIs in the Live Connect SDK (these allow developers to integrate with SkyDrive, Hotmail, and Messenger).

Skydrive-logo-200.png

This article explains how to obtain the LiveConnect SDK, add the APIs to your project, login to the service, and upload a file. The code works on Windows Phone 8. To use it on Windows Phone 7.x you need some extra jobs described here.

[edit] Prerequisites

At the time of writing this article, the LiveConnect APIs are not included by default on the Windows Phone SDK.

Before you start developing:


[edit] Creating the application

Create a new HelloWorldPhone Windows Phone application in Microsoft Visual Studio 2010 Express for Windows Phone using the Visual C# -> Silverlight for Windows Phone -> Windows Phone Application project template and name it SkyDrive:

SkyDrive-step-000.png

Choose last OS version

SkyDrive-step-001.png

Bring up the Add Reference dialog and go to the .Net tab. Scroll down and add the Microsoft.Live and Microsoft.Live.Controls assemblies to your project.

SkyDrive-step-002.png

Open MainPage.xaml in the designer. Bring the Toolbox in view and right-click to select Choose Items… Under Windows Phone Components tab, find the SignInButton control in the Microsoft.Live.Control namespace and add to your toolbox (You only need to do this once).

SkyDrive-step-003.png

If everything is well installed you should see the SignInButton control in your toolbox. Drag it onto your designer surface.

SkyDrive-step-004.png

[edit] Scopes and permissions

Before your app makes requests of the Live Connect APIs to work with Live Connect info, in most cases you must get permission from the user to access that info or to create new objects on behalf of the user. In the Live Connect APIs, this permission is called a scope. Each scope grants a different permission level.

There are three types of scopes:

  • Core scopes are central to the Live Connect APIs and involve users' core profile and contact data.
  • Extended scopes allow you to work with users' extended profile and contact data.
  • Developer scopes allow you to work with developers' client IDs.

For our sample project we need the following scopes

Core scopes

Scope Enables
wl.basic Read access to a user's basic profile info. Also enables read access to a user's list of contacts.
wl.offline_access The ability of an app to read and update a user's info at any time. Without this scope, an app can access the user's info only while the user is signed in to Live Connect and is using your app.
wl.signin Single sign-in behavior. With single sign-in, users who are already signed in to Live Connect are also signed in to your website.

Extended scopes

Scope Enables
wl.skydrive_update Read and write access to a user's files stored in SkyDrive.

Into.xaml file your code should look like that:

<my:SignInButton Content="Button" Name="skydrive" Scopes="wl.basic wl.signin wl.offline_access wl.skydrive_update" SessionChanged="skydrive_SessionChanged"  />

[edit] ClientId

Now we need to connect our application to Live Connect. Go to the application management site and click the Create Application. Create an application and provide a name for it.

SkyDrive-step-005.png

If everything goes well you will be provided with a ClientID and a Client secret code:

SkyDrive-step-006.png

Now let's add the ClientID to our SignInButton code:

<my:SignInButton Content="Button" Name="skydrive" ClientId="00000000440xxxxx" Scopes="wl.basic wl.signin wl.offline_access wl.skydrive_update" Branding="Skydrive" TextType="SignIn" SessionChanged="skydrive_SessionChanged"  />

[edit] Using SkyDrive APIs

using Microsoft.Live;
using Microsoft.Live.Controls;
 
// SkyDrive session
private LiveConnectClient client;

[edit] SkyDrive Login session management

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();
}
}

Here the login screenshot

Login screenshot

[edit] Uploading a file

First we create a Demo file to upload. Here an example of a bynary file:

private string fileName = "sample.dat";
private IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
 
private void CreateFileIntoIsolatedStorage()
{
if (isf.FileExists(fileName))
{
isf.DeleteFile(fileName);
}
 
IsolatedStorageFileStream isfStream = new IsolatedStorageFileStream(fileName, FileMode.Create, IsolatedStorageFile.GetUserStoreForApplication());
 
byte[] output = new byte[25];
 
for (int i = 0; i < 25; i++)
{
output[i] = (byte)(i);
}
 
isfStream.Write(output, 0, output.Length);
 
isfStream.Close();
}

In this example we call the method from constructor, but of course is possible to create the file when and where needed.

public MainPage()
{
InitializeComponent();
CreateFileIntoIsolatedStorage();
}

Now we can upload the file

private async void btnUpload_Click(object sender, RoutedEventArgs e)
{
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var fileStream = store.OpenFile(strSaveName, 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) {
 
}
}
}
}

[edit] BackgroundUploadAsync

Parameters

  • path
Type: String

The folder ID of the folder in SkyDrive to upload the file to, for example "folder.8c8ce076ca27823f.8C8CE076CA27823F!142"

  • uploadLocation
Type: Uri

The unique isolated storage path to where the file is to be uploaded from, for example "/shared/transfers/myFile2.txt"

  • option
Type: OverwriteOption

Specifies whether the file that's being uploaded to SkyDrive should overwrite an existing file with the same file name in that location.

[edit] Code sample

[edit] Links

This page was last modified on 9 October 2013, at 22:05.
852 page views in the last 30 days.
×