Nick LaMarca
Nick LaMarca

Reputation: 8188

Is Isolated Storage Always Necessary?

I see alot of examples on how to write data from an app to a file then put it in isolated storage. I do not want to write any data to my xml file, I just simply want to save it into isolated storage then query it later.

A few simple questions

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

 using (XmlReader reader = XmlReader.Create("bbxml.xml"))
        {
            XDocument xml = XDocument.Load(reader);
            //query xml....
}

Upvotes: 5

Views: 583

Answers (1)

Praetorian
Praetorian

Reputation: 109189

Include the XML file in your project files in Visual Studio, then in the Properties window make sure Build Action is set to Content and Copy to Output Directory is set to Copy always or Copy if newer. This will include the file in the output XAP file.

To access this file in code use:

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

Of course, it doesn't have to be XDocument, you can use any XML reader class similarly.

Upvotes: 7

Related Questions