Posted in WIN_7

windows phone 7 Storage

Windows Phone 7 Isolated storage step by step Tutorial

Steps 

1.Create  two button ,one textbox and one textblock.

iso1

2.Insert the namespace given below

using System.IO;

using System.IO.IsolatedStorage;

iso2

3.In code behind page write the code given below

namespace TextStorage
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }
      private void button1_Click(object sender, RoutedEventArgs e)
        {
            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
            isf.CreateDirectory("DATA");
            StreamWriter sw = new StreamWriter(new IsolatedStorageFileStream("DATA\\suresh.txt", FileMode.Create, isf));
            sw.WriteLine(textBox1.Text);
            sw.Close();
        }
       private void button2_Click(object sender, RoutedEventArgs e)
        {
            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
            StreamReader sr = null;
            try
            {
              sr = new StreamReader(new IsolatedStorageFileStream("DATA\\suresh.txt", FileMode.Open, isf));  
              textBlock1.Text = sr.ReadLine();                 
             sr.Close();
            }
            catch
            {
                textBlock1.Text = "Error reading file";
            }   }
    } }

4.Now run your application.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s