c# - Can't load XML from file -
what wrong here? throws argumentexception
var xmldocument = await xmldocument.loadfromuriasync(new uri("ms-appx:///livetiles/templates.xml")); is there more simple way load xml file?
thank you!
windows rt little bit special @ time of manipulating files, highly recommend blog entry:
http://blog.jerrynixon.com/2012/06/windows-8-how-to-read-files-in-winrt.html
taken link:
// settings // same (ms-appx:///myfolder/myfile.txt) var _folder = windows.applicationmodel.package.current.installedlocation; _folder = await _folder.getfolderasync("myfolder"); // acquire file var _file = await _folder.getfileasync("myfile.txt"); assert.isnotnull(_file, "acquire file"); // write content var _writethis = "hello world"; await windows.storage.fileio.writetextasync(_file, _writethis);
or simplify little bit more, approach can be:
try
{ storagefolder storagefolder = package.current.installedlocation; storagefile storagefile = await storagefolder.getfileasync("basicdata.xml"); xmltextblock.text = await fileio.readtextasync(storagefile, windows.storage.streams.unicodeencoding.utf8); } catch (exception ex) { xmltextblock.text = ex.message; }
Comments
Post a Comment