Saturday, 31 August 2013

UnauthorizedAccessException Accessing XSD In Windows Store App

UnauthorizedAccessException Accessing XSD In Windows Store App

My Windows Store app uses the FileOpenPicker to allow the user to browse
to an XML document. I can open the XML document as a stream and load it
with XDocument.Load([stream]).
But now, as I parse the XML document, I want to process schema
declarations that I find. I want to open a referenced XSD and parse it,
too, using an XDocument. The referenced XSD is in the same folder as the
main XML document. How do I open the referenced XSD? If I try to access it
by its full path name, an UnauthorizedAccessException object is thrown. I
don't want to use the FileOpenPicker again and force the user to select
the XSD ... that would make for a bad UI. I know where the XSD is ... it's
with the XML.
So how do I call XDocument.Load() on the referenced XSD without an
UnauthorizedAccessException object being thrown?

No comments:

Post a Comment