UWP app file picker exception: Access Denied to file
I'm trying to write a simple UWP app and I'm having trouble getting the picker to open a file. I've basically copied exactly as seen in the MSDN docs here.
When I try to open a file, I'm getting this error:
System.UnauthorizedAccessException
HResult=0x80070005
Message=Access to the path'
C:\Users\user\Downloads\bgbtest.gb' is denied.
Source=System.IO.FileSystem
I see in the documentation that capabilities should be set to access files outside of certain areas in a UWP application, but it also says:
In addition to the default locations, an app can access additional files and folders by declaring capabilities in the app manifest (see App capability declarations), or by calling a file picker to let the user pick files and folders for the app to access (see Open files and folders with a picker).
I'm only trying to read a file, not write or do anything fancy. Not sure where to go from here?
Posted Jul 19, 2019, 8:35 PM UTC
If I remember correctly, the picker object has a method to get a stream from the chosen file. Are you using that, or are you taking the name given to you and opening it by hand?