Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP access denied

Tags:

c#

file

uwp

Basically, I am having huge difficulty getting a text file to open by my UWP app. I have set the app permissions to be able to access files in 'my documents' and other options of known libraries like 'my pictures' but any attempt to open a file not located in these places is met by an 'Access Denied' error. From trawling the internet I know this is a known issue and has been asked a few times, but all threads seem to lead to the conclusion that you simply cannot access these files without getting the user to access it via the file picker (due to sandboxing). See thread below for example:

https://social.msdn.microsoft.com/Forums/en-US/2ab6e209-cad7-4254-a252-b8e752ea7d13/uwp-how-can-i-access-locally-stored-files-not-on-removable-storage?forum=WindowsIoT

I know asking the same question again and hoping for a different response sounds futile but I know for a fact that this cannot be the whole answer. I know this because I have downloaded other notepad apps from the store (e.g. modern notepad) and they allow this behaviour with no issues. How are they doing this???

This has been driving me mad for months and I really hope someone can help

like image 889
jarney1 Avatar asked Dec 03 '17 18:12

jarney1


1 Answers

5 months later...

It appears Microsoft have now added the capability. Simply add the 'broadFileSystemAccess' capability to the app manifest as described here: https://docs.microsoft.com/en-us/windows/uwp/files/file-access-permissions

Note that this still requires user input to some extent (the user must grant permission to file system access on first run of the app) but that the file/folder picker UI is not needed.

I haven't actually tried this yet but it sounds like it should do the job. I hope it helps people referring to this post in the future.

like image 91
jarney1 Avatar answered Oct 06 '22 15:10

jarney1