写入:
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
IsolatedStorageFile f = IsolatedStorageFile.GetUserStoreForAssembly();
using(IsolatedStorageFileStream stream = new IsolatedStorageFileStream("myFile", FileMode.Create, f))
using{StreamWriter writer = new StreamWriter(stream ))
{
foreach(TreeViewItem item in favoritesItem.Items)
writer.WriteLine(item.Tag as string);
}
}
读取:
protected overrider void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
IsolatedStorageFile f = IsolatedStorageFile.GetUserStoreForAssembly();
using(IsolatedStorageFileStream stream = new IsolatedStorageFileStream("myFile", FileMode.OpenOrCreate, f))
using{StreamReader reader = new StreamReader(stream ))
{
string line = reader.Readline();
while(line != null)
{
//读取后的逻辑
line = reader.Readline();
}
}
}