这篇文章很好的介绍了Isolated Storage。取其精华作为以后参考。

Isolated Storage的结构

快速理解WP7的Isolated Storage

示例代码如下:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
string text;
if (IsolatedStorageSettings.ApplicationSettings.TryGetValue("text", out text))
{
this.textBox1.Text = text;
}

var fileStorage
= IsolatedStorageFile.GetUserStoreForApplication();
if(fileStorage.FileExists("text.txt"))
{
using(var fin = new StreamReader(new IsolatedStorageFileStream("text.txt", FileMode.Open, fileStorage)))
{
this.textBox2.Text = fin.ReadToEnd();
}
}
}

private void button1_Click(object sender, RoutedEventArgs e)
{
IsolatedStorageSettings.ApplicationSettings[
"text"] = textBox1.Text;
}

private void button2_Click(object sender, RoutedEventArgs e)
{
var fileStorage
= IsolatedStorageFile.GetUserStoreForApplication();
using (var writer = new StreamWriter(new IsolatedStorageFileStream("text.txt", FileMode.OpenOrCreate, fileStorage)))
{
writer.Write(textBox2.Text);
}
}

 

相关文章:

  • 2021-04-28
  • 2022-12-23
  • 2021-12-18
猜你喜欢
  • 2021-06-02
  • 2022-01-22
  • 2022-01-23
  • 2021-09-10
  • 2022-12-23
  • 2021-06-24
  • 2021-05-02
相关资源
相似解决方案