首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Windows Mobile >

wp7 隔离存储有关问题

2012-03-24 
wp7 隔离存储问题private void btn_save_Click(object sender, System.EventArgs e){using (IsolatedStora

wp7 隔离存储问题
private void btn_save_Click(object sender, System.EventArgs e)
  {
  using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
  {
  if (!isf.DirectoryExists("data"))
  {
  isf.CreateDirectory("data");
  }
  using (IsolatedStorageFileStream stream =
  new IsolatedStorageFileStream(@"data\1.txt", FileMode.OpenOrCreate, isf))
  using (StreamWriter writer = new StreamWriter(stream))
  {
  writer.WriteLine(txt_msg1.Text);  
  writer.Close();
  }
  }
   
  }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
  {
  IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
  if (isf.FileExists(@"data\1.txt"))
  {
  using (IsolatedStorageFileStream stream =
  new IsolatedStorageFileStream(@"data\1.txt", FileMode.Open, isf))
  using (StreamReader reader = new StreamReader(stream))
  {
  tring txt = reader.ReadLine();
  txt_msg1.Text = txt.ToString();
  }
  }
  base.OnNavigatedTo(e);
  }
wp7的隔离存储空间存储的内容是不是当就是我把VS关闭后再打开就无法读取上一次的内容了?
因为我发现好像只要我不把VS关闭,数据内容就存在,即我按下模拟器上的start或者back键都可以调用OnNavigatedTo再次复原数据,可是关闭VS后就不能了。求高手解惑!

[解决办法]
你将部署在模拟器上的软件卸载点,在部署一边,也会发现原来的数据没有了。

独立存储空间至只对某一个应用程序而言的,当你停掉程序时,这个程序所占的独立存储控件当然还在,那么数据也肯定在,当你关闭VS的时候,你是不是将模拟器也关掉了。
模拟器关掉后,模拟器上的所有应用都会被卸载,那么,应用程序都不在了,独立存储空间的内容也就不在了嘛。呵呵。试试................祝你好运。。。。。。。。。。。

热点排行