简体   繁体   中英

Storing data in isolated storage

How can I store a variable in isolated storage and retrieve it later in a C# console application?

I know how to store data in files in isolated storage: first I need to get isolated store and then I need to create a directory and then a file under that directory and perform read/write operations on that file. I can do this with stream reader and writer

var store = IsolatedStorageFile.GetUserStoreForApplication();

IsolatedStorageFileStream rootFile = store.CreateFile("hello.txt");

store.CreateDirectory("Conditions");

How can I do the same by just using variables, with no files?

IsolatedStorageSettings is only available for silverlight.

Similar mechanism is there for Metro Apps.

But for normal desktop Applications similar class is not present.

If i have to approach, i will create similar class, MyLocalStorageSettings, and maintain a Dictionary inside it.

To any modification in dictionary i will save to disk (using IsolatedStorageFile). This dictionary should be loaded either at the time application is loaded, or at the first access to this class.

I have utilized similar approach for storing complex settings in Metro Apps , where existing infrastructure is not sufficient.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM