xml - XDocument.Save(string) not available -
i'm using vs 2012 express windows 8.i want load xml file, modify content , save disk.
up now, i've been using linq xml , i've been able load file, change node information.
i want save file disk using xdocument.save(string) method intellisense not include method though documented in online documentation.
any idea why?
thanks
---update---
here's i'm trying do
string questionsxmlpath; xdocument xmldocquestions = null; storagefile file = null; public mainpage() { this.initializecomponent(); questionsxmlpath = path.combine(package.current.installedlocation.path, "assets/template.xml"); xmldocquestions = xdocument.load(questionsxmlpath); } private async void somecodeheretopopulatecontrols() { // code populates controls on window edit xml nodes. } private async void button_click_3(object sender, routedeventargs e) { xelement elequestion = (from el in xmldocquestions.descendants("question") (string)el.element("id") == txtid.text select el).firstordefault(); elequestion.elements("description").firstordefault().replacewith(txtdescription.text); xmldocquestions.save(questionsxmlpath); // error here , can't compile }
you'll need use windows.storage apis. in sandboxed , asynchronous world of windows 8, you'll find 2 significant differences in dealing file storage:
the application can programmatically access data "local storage" application unless end-user has granted specific permission app store/read elsewhere in file system (via file , folder pickers)
reading , writing files asynchronous operation, you'll find of file access methods ending in "async" , you'll use (typically) async/await pattern leverage them
take @ file access , permissions in windows store apps topic on windows dev center more details file access sample.
in specific case, you'll end writing xdocument.tostring() desired output file using techniques shown in article , code sample cited above.
by way, more holistic , measured approach learning file system (as other concepts unique windows store programming), (free) microsoft app builder program great way spin up.
Comments
Post a Comment