skydrive upload c# metro
Posted on March 17, 2012
A preview of the latest Live SDK for Metro apps can be downloaded here https://connect.microsoft.com/site1226. This is for usage with the Windows 8 Consumer Preview (Note that the SDK is a preview version with no go-live license).
After installing you can add a reference via ‘add Reference’ > and select Windows > Extensions in the Reference Manager dialog.
In order to configure sign in on Windows Phone a client ID was required; this is different for Metro-style Apps as you now need to register your app package name and publisher identity here http://go.microsoft.com/fwlink/?LinkId=227628.
Once registered you will be provided with a new Package Name – copy this back into your app manifest.
Once this is complete, using the following code you will be able to sign in:
add this namespace declaration
and a sign in button
The Live id session status is reported by the SessionChanged event so I handle it like this, storing the session object for later use:
Next we need a way to get hold of an image so I just used the File Picker to retrieve one (I added a way to capture an image using the camera but I couldn’t test it so it probably won’t work )
Here’s the code for the file picker:
and finally, what it was all about, uploading to skydrive:
Here’s the ui whilst uploading an image:
and when completed – displaying the json result returned by the upload.
and finally, the image on skydrive.
The project can be found here https://skydrive.live.com/redir.aspx?cid=4f1b7368284539e5&resid=4F1B7368284539E5!441&parid=4F1B7368284539E5!123