Silverlight - Using Isolated Storage

Play Silverlight - Using Isolated Storage

The Discussion

  • User profile image

    Simply the best.

  • User profile image
    Pawan Venugopal

    Great Post.


    What if i have a .asx file in IsoStore and how do i return it as a file to a silverlight control like media element.

  • User profile image

    You can also use the XmlSerializer (from System.Xml.Serialization) to save ur data in a XML file:
    // Save method:
                using (var file = IsolatedStorageFile.GetUserStoreForApplication())            {                var xs = new XmlSerializer(typeof(List<Rect>));                using (IsolatedStorageFileStream stream = file.CreateFile("rects.xml"))                {                    xs.Serialize(stream, list);                    stream.Close();                }            }
    And reading is easy to:
    // Load method:
                using (var file = IsolatedStorageFile.GetUserStoreForApplication())            {                // NOTE: you should check if file exist..                var xs = new XmlSerializer(typeof(List<Rect>));
                    using (IsolatedStorageFileStream stream = file.OpenFile(FILENAME, FileMode.Open))                {                    list = (List<Rect>) xs.Deserialize(stream);                    stream.Close();                }

  • User profile image

    oh boy.. thats not readable. it didn't save the text formatting.. sorry about that.
    click the link below for a more readable version of the code:

Add Your 2 Cents