View your WP7 App’s Isolated Storage Structure (with source code)

Working with the Isolated Storage within the Windows Phone 7 emulator can be quite tricky. Firstly, there are often exceptions thrown that don’t always explain what the root cause of the error is. Secondly, it’s often difficult to figure out the structure of your Isolated Storage, especially as more directories and files are created. Therefore, I decided to write a quick class (IsoViewer.cs) which makes it easier to get an overview of the structure of your Isolated Storage.

It will display the directories present and their subdirectories. It will also display all the files within the folders. The class is easy to use and, by default, displays the structure using Debug.WriteLine so you’ll be able to see it within the Output window of Visual Studio. Of course, this can easily be changed, so you can route the information to an external file or have it displayed elsewhere. In order to use the class, simply add it to your project and call it with IsoViewer.GetIsolatedStorageView(pattern, IsolatedStorageFile) – simple. To display all files, simply use “*” as the pattern. The class is static, so there’s no need to create an instance of it.

Download IsoViewer Source Code

Hope you find this useful! If you have any problems with the code, feel free to comment and I’ll try and get them fixed.

Updated (13/08)

A small update – If you don’t have any directories, and only files in the root directory, then the files aren’t displayed. Add “if (directories.Length == 0) GetFiles(root, “*”, storeFile);” on Line 49 (after initialisation of string[] directories) to fix this. (I’ve updated the source code in the download already)

Retweet This Post

@keyboardP

Share

Advertisements

10 Responses to View your WP7 App’s Isolated Storage Structure (with source code)

  1. Pingback: Oleksandr Krakovetskiy blog

  2. Kayos says:

    KeyboardP, Gr8! looks like a handy class.
    can you pl. provide the download from another location? looks like this url is being blocked at my office.
    Thanks.

    • keyboardP says:

      Hi Kayos,
      I’ve added it to my DropBox . Let me know if this link works.
      http://dl.dropbox.com/u/14268254/IsoViewer.zip

      If not, I could send it to the email account that you posted with.
      Hope that helps

  3. Joey says:

    Hi, I am new to wp7 programming.

    All I need is code that will find all files in a certain directory. This seems to do exacly that.

    What goes into the IsolatedStorageFile variable?

    Thanks

    • keyboardP says:

      Hi Joey,
      You’ll want to get the IsolatedStorage for your particular application. To do this, use “IsolatedStorageFile.GetUserStoreForApplication()” as the variable input. Check out this MSDN page for some good info on using IsolatedStorage.

      • Joey says:

        Wow thanks for the quick reply.

        I got it working! Thanks!

        But I do have one question, is the only way a program can access any file is if it creates it? I would like to load a txt file on installation… Does this have to be done though code only?

      • keyboardP says:

        You’re welcome!
        If your text file is included in your project, then you can access it in various ways. One way is to use Application.GetResourceStream. This will give you access to your text file that’s included.
        Alternatively, if you don’t mind using an XNA assembly in your project, you can use TitleContainer.OpenStream. Check the second example in this post

        On a side note, your application runs in it’s own isolatedstorage. Therefore, it can only access files within that storage (unless you use the various Launchers and Choosers WP7 gives). However, you can’t directly access files from another application from within yours.
        Hope that helps 🙂

  4. Phil Farrand says:

    Great piece of code. Very useful. Was downloading some files from the internet in my app and being able to dump the contents of the isolated memory helped me debug! Thanks for your help!

    • keyboardP says:

      You’re welcome, Phil!

  5. Pingback: 超快递 beta版 » Windows Phone 7 资源汇总(超全)

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: