且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Windows 手机上存储数据

更新时间:2023-02-26 22:10:08

一个非常简单的解决方案是使用 IndependentStorageSettings.设置是一个值字典.您可以访问此类设置

A very simple solution is to use the IsolatedStorageSettings. The settings is a dictionary of values. You access settings like such

IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

bool useLocation;
if (settings.TryGetValue("UseLocation", out useLocation) == false)
{
    // provide a default value if the key does not exist
    useLocation = true;
}

然后您可以像这样保存设置

You then can save settings like such

IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

settings["UseLocation"] = value;
settings.Save();

更好的是创建一个不错的 Settings 类来为您处理所有这些.这是一个不错的博客 详细说明如何做到这一点的帖子.

Even better is to create a nice Settings class to take care of all of that for you. Here is a nice blog post detailing how to do that.