UWP DataTable WriteXML Access Denied

Sean Liming 4,511 Reputation points
2020-07-31T02:48:42.557+00:00

In my UWP application, I have setup a datatable (myTable) by adding the columns and then the rows. Then I make a call to save the database table to an XML file by simply calling myTable.WriteXml("Path to XML",XmlWriteMode.WriteSchema). The WriteXml call fails with System.UnauthorizedAccessException: "Access to the path "....' is denied. The broadFileSystemAccess has been added to the appxmanifest file.

Is there some other capability that needs to be added to the appxmanifest file?

Regards,

Sean

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Roy Li - MSFT 32,231 Reputation points Microsoft Vendor
    2020-07-31T04:16:27.86+00:00

    Hello,

    Welcome to Microsft Q&A!

    This is the expected behavior. The broadFileSystemAccess capability only works for Windows.Storage APIs. This is mentioned in the document-Restricted capabilities. That's why you will get the exception when you trying to call the writexaml method. If you are not using Windows.Storage APIs, please still put the target file to the places that UWP apps have default permission.

    Thank you.


0 additional answers

Sort by: Most helpful