Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open and save files on skydrive from managed code (with file selection)

What is correct/recommended way of letting the user choose a save or open- location on SkyDrive from a windows phone 8 app written in c#?

I have tried the FileOpenPicker as it is used in Windows 8 Apps, however it seems only to work from C++ (unmanaged) and if I have seen right, it only will support multi-media files

From MSDN: Windows Phone 8
This API is supported in native apps only.

like image 317
HCL Avatar asked Dec 28 '12 12:12

HCL


1 Answers

Unlike Win8, there aren't built-in mechanisms in WP8 that allows access to SkyDrive. The FilePicker class in WP8 has been overloaded in native apps since they don't have access to managed APIs. FilePicker in the same sense as Win8's FilePicker doesn't exist in WP8. Specifically WP8's FilePicker is used to replace the managed PhotoChooserTask since it's only available to managed apps.

If you want to access SkyDrive you can do so using SkyDrive's REST services or a wrapper around them (Specifically the Live SDK). For example here's Live SDK SigninButton and handling sign-in:

<live:SignInButton x:Name="btnSignin" Scopes="wl.signin wl.basic" SessionChanged="btnSignin_SessionChanged" />

private void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
{
    if (e.Status == LiveConnectSessionStatus.Connected)
    {
        session = e.Session;
        client = new LiveConnectClient(session);
        infoTextBlock.Text = "Signed in.";
    }
    else
    {
        infoTextBlock.Text = "Not signed in.";
        client = null;
    }
}

However, because these are 3rd party APIs & SDKs the user must authenticate using a username and password within your app. That's pretty bad since that basically gives you free reign of user's private data to SkyDrive. Not to mention complete control over everything else powered by Live authentication. So most apps tend to avoid SkyDrive access unless it's core functionality to them.

like image 167
JustinAngel Avatar answered Nov 15 '22 12:11

JustinAngel