Installation Folder in Windows Phone 8

2 Nov

The installation folders for Windows Phone apps (also known as appdata) are read-only and reading data from files in the folders hasn’t always been the best experience. We have been able to use GetResourceStream to stream files from the appdata folder and DataContext to work with a local database.

With Windows Phone 8 we got some improvements. We got a new property of the current package called InstalledLocation. It returns the installation folder as a StorageFolder and using the Path property it’s possible to get the full path of the installation folder. Using the StorageFolder we are able to work with the files in the appdata folder.

The content of the appdata folder can easily be accessed using the appdata or ms-appx URI scheme names. Although the two schemes point to the same location, there is an important difference in the usage of the two. Use “ms-appx:///” for accessing the appdata folder with APIs that are part of the new Windows Phone Runtime (part of the Windows namespace). In all other APIs use “appdata:/”.

If we want to get a file asynchronisly we can use Windows.Storage.StorageFile.GetFileFromApplicationUriAsync
to access the file. As the API is part of the new Windows Phone Runtime, it is required we use “ms-appx:///” to access our file:

If we just want to specify an Uri we can use “appdata:/”:

// thomas

One Response to “Installation Folder in Windows Phone 8”

Trackbacks/Pingbacks

  1. Windows Phone 8 SDK is now available « xamlgeek - November 2, 2012

    […] Installation Folder in Windows Phone 8 […]

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: