JeffFerguson
JeffFerguson

Reputation: 3002

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?

Upvotes: 0

Views: 113

Answers (1)

MarcinJuraszek
MarcinJuraszek

Reputation: 125650

You can't take any file from outside application Local Storage without use permission, so you have to use FileOpenPicker again. It's security limitation and you cannot bypass it.

Upvotes: 1

Related Questions