WP7开发 设置保存与读取 IsolatedStorageSettings的使用
在Android中,我们可以用SharedPreferences保存设置,在WP7中,可以用IsolatedStorageSettings。
写入设置:
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
settings["end_Station"] = textBox2.Text;
settings.Save();//保存
//把textBox2的Text属性用end_Station这个key保存
读取设置:
object end_Station;
if (settings.TryGetValue("end_Station", out end_Station))
{//尝试把key为end_Station的值读到end_Station里,类型为Object,如果读取失败,就返回false,就不会执行下面的语句
//或者settings.TryGetValue(key,out value),这种形式,读出的直接就是string
textBox2.Text = (string)end_Station;
}
© 2011, 冰冻鱼. 请尊重作者劳动成果,复制转载保留本站链接! 应用开发笔记