Silverlight IsolatedStorage removed when application is shutdown?

末鹿安然 提交于 2019-12-25 02:15:24

问题


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:

Is Silverlight isolated storage treated as permanent, or as a cache?

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")

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.

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


回答1:


1- Use the SiteSettings instead of ApplicationSettings

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

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

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



来源:https://stackoverflow.com/questions/5353323/silverlight-isolatedstorage-removed-when-application-is-shutdown

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!