Is isolated storage always available?

I see many examples of how to write data from an application to a file, and then put it in isolated storage. I don’t want to write any data to my XML file, I just want to save it in isolated storage and then request it later.

Some simple questions

  • Someone has code on how to put an existing xml file into isolated storage. Also, since I am not writing to this file, do I still need isolated storage? Can I just add xml to my project and use Linq for xml to open it, request it and close it with the click of a button?

  • I want to request xml through my application in the background. I see many examples for serialization, do I need to do this? Can I just open the xml file and use linq for xml to request data?

Can I just do this, set bbxml.xml to Content and forget about isolated storage and just do it?

 using (XmlReader reader = XmlReader.Create("bbxml.xml"))
        {
            XDocument xml = XDocument.Load(reader);
            //query xml....
}
+5
source share
1 answer

Include the XML file in the project files in Visual Studio, then in the properties window, make sure that the parameter is Build Actionset to Contentand is Copy to Output Directoryset to Copy alwaysor Copy if newer. This will include the file in the XAP output file.

To access this file in code, use:

XDocument doc = XDocument.Load( "path/to/my/file.xml" );

, XDocument, XML .

+7

All Articles