类似于平时的IO数据流,直接贴相关的代码:
写入:
IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
using(IsolatedStorageFileStream stream = new IsolatedStorageFileStream(STATUS_NAME,FileMode.Open,store))
{
using (StreamWriter writer = new StreamWriter(stream))
{
writer.WriteLine(...);
writer.Flush();
}
}
读出:
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(STATUS_NAME, FileMode.OpenOrCreate, store))
{
using (StreamReader reader = new StreamReader(stream))
{
... = reader.ReadLine();
}
}
独立存储就这么简单,当然了,如果心情好的话,可以选择使用xml。
最后再说一句,别忘了引入:
using System.IO.IsolatedStorage;
using System.IO;