Using IsolatedStorage

For the past couple of days I’ve been having a play with Isolated Storage in c# and I quite like how easy it has become to do this kind of thing. Isolated Storage is great if you just want to persist some data which your users want to keep (maybe simple user settings etc…) but its not an encrypted file format so DONT keep anything sensitive in these files since anything can effectively read them (unless you encrypt the data youself that is !)

Typically (for this post) I wont go into long reams of text telling you what it is and what you can do i will just show you the code because that’s all we are really interested in anyway.

First using the IsolatedStorageFileStream object. This will create the file for you in your Users\\AppData\IsolatedStorage folder.

                IsolatedStorageFileStream isoFile= new System.IO.IsolatedStorage.IsolatedStorageFileStream("MyFile", System.IO.FileMode.Create);
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(isoFile, "Some Data");

And then to read it back again, its simply this.

                IsolatedStorageFileStream isoFile= new IsolatedStorageFileStream("MyFile", System.IO.FileMode.Open);
                BinaryFormatter bf = new BinaryFormatter();
                object n = bf.Deserialize(isoFile);

In the examples above all the ‘magic’ happens in the Serialize and Deserialize methods of the BinaryFormatter.

So, now that you have seen a simple file being added, lets create a basic folder structure to
hold the data.

   IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain,null,null);

                if (!isoFile.DirectoryExists(@"MyTempFilePath")){
                IsolatedStorageFileStream file = isoFile.CreateFile("MyFile", @"MyTempFilePath"));
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(file, "Some Data");

In this example i create an IsolatedStorageFile setting the Storage Scope and then attempt to create a simple folder called “MyTempFilePath” after which I then create a file at the location. You can use similar syntax to retrieve the data from this location. I wont show it here because its just a repeat of whats been shown previously.


  1. Hey I know this is off topic but I was wondering
    if you knew of any widgets I could add to my blog that automatically tweet my newest twitter
    updates. I’ve been looking for a plug-in like this
    for quite some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading your blog and I look forward
    to your new updates.

    my homepage …

  2. Victor worked for Aspen Commercial Security and has been continually grateful for
    the knowledge they have shared with him.
    In addition, you might need to have an electronic key replaced and a locksmith can also
    perform this service. Only the pins and tumblers
    of the locks are replaced, thereby invalidating existing keys.

    Feel free to visit my web page – לחץ לצפיה

  3. I think this is among the most significant info for
    me. And i’m glad reading your article. But want to remark on some basic things, the web site style
    is ideal, the articles are very great. Excellent job, many thanks.

    Also visit my web page … Emergency Plumber, Lynette,

  4. I actually adore the theme on your website, I run a web site, and i would adore to
    utilize this theme.

    Feel free to visit my homepage dentist in melbourne fl [Marvin]

  5. I do not think I’ve read something just like this before.
    So excellent to find anyone with some original
    views on this subject. thank you for sharing this up. This site is
    one thing that is needed online, somebody with
    somewhat creativity. Great job for bringing a little
    something fresh to the internet!

    Stop by my web page … aberdeen emergency (Marsha)

  6. Hey there! I know this is kinda off topic but I was wondering if you knew where I could get a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having difficulty finding one?
    Thanks a lot!

  7. Victor worked for Aspen Commercial Security and has been continually grateful for the knowledge they have shared with
    him. Here are several things you are able to do to prevent these types of
    situations:. Only the pins and tumblers of the
    locks are replaced, thereby invalidating existing keys.

    Also visit my web-site; ראה קליפ

  8. I absolutely love your blog and find almost all
    of your post’s to be exactly I’m looking for. Would you offer guest writers to write content
    in your case? I wouldn’t mind composing a post or elaborating on many of the subjects you
    write with regards to here. Again, awesome web site!

  9. Hello there! This post could not be written any better! Looking through this article reminds
    me of my previous roommate! He constantly kept preaching about this.
    I’ll forward this article to him. Fairly certain he will have a
    great read. I appreciate you for sharing!

    Here is my web page Raymundo

  10. It could be neat to see, for instance, an integration with the popular communication device Slack ,
    a PCMag Editors’ Choice, to share polls rapidly with a
    team or get alerts about exercise on polls.

Comments are closed.