Software Architecture – Isolated Storage Introduction

Silverlight application works on client end browser, after downloading from web server.
Silverlight provide isolated storage which provides file system based storage space for storing the data on client side.

Isolated storage can act like cookies in ASP .Net, so used in saving session related data about session and application state. Secondly media data like video/audio files can be saved on client end, for second time fast access and manipulation.

On silverlight page, right click to see the configuration screen for isolated storage as:


Sample Code

Lets follow a simple application for reading and writing to isolated storage which will look like as:


Code to save data will look like as:

            using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("data.txt", FileMode.Create, isoStore))
                {
                    using (StreamWriter writer = new StreamWriter(isoStream))
                    {
                        writer.Write(datatowrite.Text);
                    }
                }

            }

Code to read data will look like as:

using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream isoStream =
                    new IsolatedStorageFileStream("data.txt", FileMode.OpenOrCreate, isoFile))
                {
                    using (StreamReader sr = new StreamReader(isoStream))
                    {
                        dataread.Text = sr.ReadToEnd();
                    }
                }

Reference:
www.silverlight.net

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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

%d bloggers like this: