Reputation: 925
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
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