Using Isolated Storage for your Windows Phone 7 (WP7) App

Similar to other smart phone operating systems, Windows Phone 7 (WP7) does not allow applications to directly access the local file system as you would on Windows. The purpose for this restriction is to prevent other applications from making changes to your application's data. Thus, in order to access your application's data you will need to use the System.IO.IsolatedStorage namespace. Isolated Storage provides support for accessing settings as well as read/writing files.


Just about every application will have the need to store some level of settings for user preferences. To access settings first we need to create the IsolatedStorageSettings object as shown below. (Again these classes exist within the System.IO.IsolatedStorage namespace).

private IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;

It is common to declare a private appSettings object within pages you need to access settings. The appSettings object is basically a dictionary and can be used as such.

appSettings["Setting1"] = "New Value";

string value = (string)appSettings["Setting1"];

As you can see these statements show how to set and retrieve a setting called Setting1. For retrieving a setting you will need to specify the type you need. Any changes made to the appSettings object will automatically save when it goes out of scope or you can explicitly call Save().

Local File Storage

Local File storage through Isolated Storage is the primary method for storing data on WP7. Similar to settings we first need to create an IsolatedStorageFile object as shown below.

using (IsolatedStorageFile myStorage = IsolatedStorageFile.GetUserStoreForApplication())

Using the myStorage object we can now perform many of the common tasks you would expect including: creating/deleting folders, checking for existing files, create/open/delete files, etc. Here is a simple example of how to create a data directory and access a single file within it.

using (IsolatedStorageFile myStorage = IsolatedStorageFile.GetUserStoreForApplication()) 
 //Create the data directory if it doesn't exist 
 if (!myStorage.DirectoryExists("data")) 
 string filepath = "data/test.txt"; 
 using (IsolatedStorageFileStream fstream = myStorage.OpenFile(filepath, System.IO.FileMode.OpenOrCreate)) 
 // Read/Write data 

As you can see from the above code we are creating the myStorage object to get access to Isolated Storage. Then we check to see if our data directory exists and if not, create it. Next we open/create a file called test.txt in the data directory. Once you have the stream for the file you can then perform the various tasks you would expect to perform such as reading/writing data, serialize/deserialize objects, etc.


As you see, using Isolated Storage for storing settings and/or traditional file data is a rather simply process. However, it is important to note that for the initial release of WP7, Isolated Storage is the only method of storing data locally on the phone. In other words, WP7 does not include a local database such SQLite or other similar SQL database. As of the time of this writing, future versions of WP7 including Mango to be released late 2011 will include a local database. In the meantime, Isolated Storage is the primary means of storage. Nonetheless, Isolated Storage is easy to utilize and with a little creativity it is possible to suit your local storage needs.

About the Author

Chris Bennett

Chris Bennett is a Manager with Crowe Horwath LLP in the Indianapolis office. He can be reached at

Related Articles


  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • On-demand Event Event Date: February 12, 2015 The evolution of systems engineering with the SysML modeling language has resulted in improved requirements specification, better architectural definition, and better hand-off to downstream engineering. Agile methods have proven successful in the software domain, but how can these methods be applied to systems engineering? Check out this webcast and join Bruce Powel Douglass, author of Real-Time Agility, as he discusses how agile methods have had a tremendous …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date