Storage on Windows Phone 7

File storage an integral part of an application. One might think of saving a xml file with all the settings of the application in it to the local storage of the application. Its easy to do it on a windows application or console application but what if we want to do it on Windows Phone 7 … ? Its a question many people ask that where to store a file on applications storage in windows phone 7. The answer is Microsoft has provided each application with its storage space. A programmer can get the storage by a simple API call of getuserstorageforapplication and it will return the whole storage place that application has on phone for storing local files and cache materials may be. The storage on which this store is available is known as IsolatedStorageFile. One can access a file in a stream easily through it and as we know there are some great wrappers available in .Net to work with streams. Including the StreamReader and StreamWriter we commonly use. One can get stream from file storage by many mechanisms an easy and fast to access file storage in windows phone 7 has been illustrated. Its really simple how we can work with file storage in windows phone 7 see how i have simply performed read and write operations over a file.

Some basic explanation, the complete code can be found on this link


// This is how to get a storage place from the application, through IsolatedStorageFile class provided by .Net framework
var appStorage = IsolatedStorageFile.GetUserStoreForApplication());

// This is how we get a stream from the storage to work on, then we can easily pass the current stream to the stream wrappers provided in .Net framework already
IsolatedStorageFileStream stream = new IsolatedStorageFileStream(fileName, FileMode.Create, appStorage);

Do comment and wait for more blog posts in near future. Keep visiting the blog for more technical stuffs and news :)

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