1

如何将变量存储在隔离存储中并稍后在 C# 控制台应用程序中检索它?

我知道如何将数据存储在隔离存储中的文件中:首先我需要获取隔离存储,然后我需要创建一个目录,然后在该目录下创建一个文件并对该文件执行读/写操作。我可以用流读取器和写入器做到这一点

var store = IsolatedStorageFile.GetUserStoreForApplication();

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

store.CreateDirectory("Conditions");

我怎样才能通过只使用变量而不使用文件来做同样的事情?

4

1 回答 1

0

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.

于 2012-05-17T10:29:15.340 回答