【发布时间】:2017-06-03 14:08:12
【问题描述】:
我正在使用 Visual Studio 2017 并尝试为 Windows 手机编写 C# UWP 应用程序。当我尝试在主机和模拟器(移动模拟器 10.0.15063.0)之间测试漫游应用程序数据时,数据不同步。即使等了几个小时。模拟器似乎可以跨设备同步我的电子邮件和日历。当我在主机上搜索文件时,它似乎已正确创建:
C:\Users\Owner\AppData\Local\Packages\23840StartPoint.StartPointRunning_x6wjmepvaasdr\RoamingState
我已经检查了包清单并且包名称和版本匹配。我尝试了几种不同的选择,但没有任何效果。我是不是错过了什么。
来自 GitHub 的应用程序数据示例是我用来自学编写/读取文件的模型。它也不适用于我的设置。
var applicationData = ApplicationData.Current;
ulong storage = applicationData.RoamingStorageQuota;
//Create file client.txt => store data => Roaming folder
ApplicationDataContainer roamingSettings = ApplicationData.Current.RoamingSettings;
StorageFolder roamingFolder1 = ApplicationData.Current.RoamingFolder;
StorageFile file1 = await roamingFolder1.CreateFileAsync(Filename1, CreationCollisionOption.ReplaceExisting);
SetUpFlag = "true";
String string6 = Views.Colors101.m_BackGroundColor + ";" + Views.Colors101.m_CalendarColor + ";" + Views.Colors101.m_HeaderColor;
String toWrite = SetUpFlag + ";" + string6;
StorageFile xfile1 = await roamingFolder1.GetFileAsync(Filename1);
await FileIO.WriteTextAsync(xfile1, toWrite);
ApplicationData.Current.SignalDataChanged();
【问题讨论】:
-
如何在pc和uwp之间共享数据??
-
我正在通过漫游文件夹共享一个小文本文件(大约 150 字节)。我是新手,不确定如何在我的评论中添加代码。你能推荐一个方法吗。我尝试添加反引号但没有用。
-
您可以编辑您的原始问题以添加相关代码 sn-p 和其他更新。
-
您能否在您的设备上测试official sample?如果您有条件,能否请您在电脑和其他手机设备上测试您的项目?
-
太好了,我一定会试试这个。来自 GitHub 的应用程序数据示例是我用来自学编写/读取文件的模型。它在我的设置中也不起作用。请参考添加到我的原始问题中的代码。