写
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 }
读
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 }
删
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); isf.DeleteFile("Weather.txt");