【问题标题】:Application Data c# win mobile 8 not working as described应用程序数据 c# win mobile 8 未按描述工作
【发布时间】:2013-11-30 19:07:19
【问题描述】:
我正在尝试设置本地设置,以便可以将数据存储在我的 Windows Mobile 8 应用程序中。我正在尝试的第一步是:
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
在我的代码中添加它会导致应用在我的设备上进行调试时失败。
有什么想法吗?
我设置了"using Windows.Storage;"。实际代码不会抛出任何错误。
【问题讨论】:
标签:
c#
visual-studio-2012
windows-phone-8
storage
application-data
【解决方案1】:
我需要使用IsolatedStorageSettings 功能,如下:
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
if (!settings.Contains("test"))
{
settings.Add("test", urlText.Text);
}
else
{
settings["test"] = urlText.Text;
}
settings.Save();