在 OneDrive 上创建文本文件以设置和获取数据

Create Text file on OneDrive to set and get data

是否有任何代码片段可以帮助我完成该任务?

我在 Universal Windows 10 应用程序上工作,希望用户将他们的设置保存在 OneDrive 上,以便稍后从任何其他设备获取它们。

感谢所有帮助

Here 您可以找到示例和 api 文档。

// 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);
}