在应用程序关闭时将Silverlight IsolatedStorage删除了吗? [英] Silverlight IsolatedStorage removed when application is shutdown?

查看:74
本文介绍了在应用程序关闭时将Silverlight IsolatedStorage删除了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我发现的情况来看,除非用户手动将其删除,否则似乎IsolatedStorage应该是永久的.以下线程也是如此:

From what I can find, seems like the IsolatedStorage supposed to be permanent unless the user delete it manually. And the following thread says so too:

Silverlight隔离存储是否被视为永久存储,还是作为缓存?

但是,如果我关闭我的应用程序并重新启动它(因为我正在调试模式下调试-不确定是否会有所不同),我先前存储的数据就消失了.

However seems like if I shut down my application and restart it (as I am debugging on debug mode - not sure if that makes a different), the data I stored earlier is gone.

例如,就像伪代码一样:

For example, just as pseudocode:

onClick =
   let storage = IsolatedStorageSettings.ApplicationSettings
   let x = storage.Item key
   storage.Add(key, "Some Value")

在首次点击事件中,"x"为预期的空值(或为空).然后在第二次,x将具有某些值"-一切都按预期工作.但是,当我停止调试并重新启动应用程序时,第一次,"x"返回为null或为空.使用SiteSettings进行了相同的尝试.

on first click event, "x" is null (or empty) as expected. Then on the 2nd time around, x would have "Some Value" - this all works fine as expected. However, when I stop debugging, and restart the application, first time around, "x" goes back to null or empty. Tried the same using SiteSettings.

所以在我看来,IsolatedStorage毕竟不是永久性的吗?只是随着应用程序的生命周期发展?

So seems to me IsolatedStorage is not permanent afterall? Just goes with the lifetime of the application?

推荐答案

1-使用SiteSettings代替ApplicationSettings

1- Use the SiteSettings instead of ApplicationSettings

System.IO.IsolatedStorage.IsolatedStorageSettings.SiteSettings("YourKey") = yourValue

System.IO.IsolatedStorage.IsolatedStorageSettings.SiteSettings("YourKey") = yourValue

2-您需要在更改数据后保存数据

2- You need to save the data after you change them

System.IO.IsolatedStorage.IsolatedStorageSettings.SiteSettings.Save()

System.IO.IsolatedStorage.IsolatedStorageSettings.SiteSettings.Save()

这篇关于在应用程序关闭时将Silverlight IsolatedStorage删除了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆