Silverlight独立存储

 1   private void Button_Click_1(object sender, RoutedEventArgs e)
 2         {
 3             IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
 4             using (Stream stream=isf.CreateFile("Weather.txt"))
 5             {
 6                 using (StreamWriter writer=new StreamWriter(stream))
 7                 {
 8                     writer.WriteLine(time.Text);
 9                     writer.WriteLine(time1.Text);
10                     writer.WriteLine(time2.Text);
11                     writer.WriteLine(time3.Text);
12                 }
13             }
14         }
View Code

 1  private void Button_Click_2(object sender, RoutedEventArgs e)
 2         {
 3             IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
 4             if (isf.FileExists("Weather.txt"))
 5             {
 6                 using (Stream stream = isf.OpenFile("Weather.txt", FileMode.Open))
 7                 {
 8                     using (StreamReader reader = new StreamReader(stream))
 9                     {
10                         string line = reader.ReadToEnd();
11 
12                     }
13                 }
14             }
15         }
View Code

IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
isf.DeleteFile("Weather.txt");

 

 

 

posted @ 2014-06-24 11:28  银河系上的地球  阅读(143)  评论(0编辑  收藏  举报