Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在OneDrive上创建文本文件以设置和获取数据_C#_Authentication_Uwp_Onedrive - Fatal编程技术网

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

C# 在OneDrive上创建文本文件以设置和获取数据,c#,authentication,uwp,onedrive,C#,Authentication,Uwp,Onedrive,有没有代码片段可以帮助我完成这项任务 OneDrive的身份验证 在文本文件中保存一些变量,然后将该文件上载到OneDrive。 从OneDrive获取变量(如果存在)。 我使用通用Windows 10应用程序,希望用户将其设置保存在OneDrive上,以便以后从任何其他设备获取设置 非常感谢所有帮助您可以找到样本和api文档。您可以找到样本和api文档 // Create a simple text file at onedrive:\Apps\<your UWP name>\So

有没有代码片段可以帮助我完成这项任务

OneDrive的身份验证 在文本文件中保存一些变量,然后将该文件上载到OneDrive。 从OneDrive获取变量(如果存在)。 我使用通用Windows 10应用程序,希望用户将其设置保存在OneDrive上,以便以后从任何其他设备获取设置

非常感谢所有帮助

您可以找到样本和api文档。

您可以找到样本和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);
}