wbadry
wbadry

Reputation: 925

Create Text file on OneDrive to set and get data

Is there any code snippet to assist me in that task?

I work on Universal Windows 10 app and want users to save their settings on OneDrive to get them later from any other device.

All help is appreciated

Upvotes: 1

Views: 2667

Answers (2)

Jeffrey Tippet
Jeffrey Tippet

Reputation: 3006

// Create a simple text file at onedrive:\Apps\<your UWP name>\Some Folder\Some File.txt

// GetUniversalClient won't work until you associate your app with the store
var onedrive = OneDriveClientExtensions.GetUniversalClient(new[] { "wl.signin", "onedrive.appfolder" });
await onedrive.AuthenticateAsync();

using (var stream = new MemoryStream(Encoding.UTF8.GetBytes("Hello onedrive")))
{
    await onedrive.Drive.Special.AppRoot
        .ItemWithPath("Some Folder/Some File.txt").Content
        .Request().PutAsync<Item>(stream);
}

Upvotes: 3

Kabilan Senapathy
Kabilan Senapathy

Reputation: 134

Here you can find samples and api documentations.

Upvotes: 1

Related Questions