开发者

Is Isolated Storage Always Necessary?

开发者 https://www.devze.com 2023-02-25 01:38 出处:网络
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 t

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

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

  • I wanna query the xml through my application in the background. I see alot of examples on serializing, do I need to do this? Can I just open the xml file and use linq to xml to query the data?

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.Lo开发者_StackOverflowad(reader);
            //query xml....
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消