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:
if (e.Status == LiveConnectSessionStatus.Connected)
_liveConnectSession = e.Session;
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:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
_filename = file.Name;
BitmapImage bitmapImage = new BitmapImage();
_stream = (FileRandomAccessStream)await file.OpenAsync(FileAccessMode.Read);
myImage.Source = bitmapImage;
and finally, what it was all about, uploading to skydrive:
var liveConnectClient = new LiveConnectClient(_liveConnectSession);
liveConnectClient.UploadCompleted += LiveConnectClientUploadCompleted;
VisualStateManager.GoToState(this, "Busy", true);
liveConnectClient.UploadAsync("me/skydrive", filename, true, data, data);
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
1 thought on “skydrive upload c# metro”
Thank you for the steps in simple language. I am not sure which one to use Azure Blob storage or Skydrive. Skydrive is free but I never used on my applications. Do you have any comments.