The code is simple and suitable for beginners
First, add several widgets on the foreground page.
1 <! -- Contentpanel-place other content here --> 2 <grid X: Name = "contentpanel" grid. row = "1" margin = "380,"> 3 <textbox name = "isotextbox" 4 Height = "70" 5 width = "" 6 margin =, 33,467 "7/> 8 <textblock name =" quotatextblock "margin =" 12,164, 0, 0 "9 horizontalalignment =" Left "10 verticalalignment =" TOP "Height =" 50 "width =" 438 "/> 11 <button name =" iso_button "12 Height =" 70" 13 width = "180" 14 content = "write" 15 click = "iso_button_click" 16/> 17 <button name = "iso_button1" 18 Height = "70" 19 width = "180 "20 content =" read "21 click =" iso_button_click1 "margin =" 138,327,138,210 "/> 22 <textblock Height =" 50 "horizontalalignment =" Left "margin =" 9,231, 438 "name =" freetextblock "verticalignment =" TOP "width =" "/> 23 </GRID>
Background code Initialization
1 Loaded += new RoutedEventHandler(MainPage_Loaded);
1 void MainPage_Loaded(object sender, RoutedEventArgs e)2 {3 IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication();4 5 quotaTextBlock.Text = String.Format("quota:{0}", appStorage.Quota.ToString());6 7 freeTextBlock.Text = String.Format("free:{0}", appStorage.AvailableFreeSpace.ToString());8 }
Write button Event code
1 private void Iso_Button_Click(object sender, RoutedEventArgs e) 2 { 3 IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication(); 4 string fileName = "test.txt"; 5 6 7 using (IsolatedStorageFileStream appStream = appStorage.OpenFile(fileName, System.IO.FileMode.OpenOrCreate)) 8 { 9 using (StreamWriter writer = new StreamWriter(appStream))10 {11 writer.Write(isoTextBox.Text);12 }13 }14 }
Read button Event code
1 private void Iso_Button_Click1(object sender, RoutedEventArgs e) 2 { 3 using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication()) 4 { 5 using (StreamReader reader = new StreamReader(appStorage.OpenFile("test.txt", FileMode.Open))) 6 { 7 isoTextBox.Text = reader.ReadLine(); 8 } 9 }10 11 }
This is the end.
Isolatedstoragefile is used for independent storage to store the content in the test.txt file.
Then, you can use streamreader to read and retrieve data.
Upload 1 minute ago
Download Attachment(23.32 KB)
Source code download http://vdisk.weibo.com/s/6VCiW