- Home /
UnauthorizedAccessException: Access to path is denied error
Hello, everyone!
I created a plugin for android that allows a user to pick a file from either external or internal storage of the phone. That part works fine. I'm running on Android 6.0.1. I've also allowed all permissions needed.
However, i'm having problems when I'm trying to access the said file for upload later. Using this line of code:
FileStream file = new FileStream("filePath", FileMode.Open);
When I'm trying to get file from the internal storage, I could upload it without problem. The value of the filePath is
/storage/emulated/0/Download/demo.apk
When I try to get file from my SD card, I get UnAuthorizedAccessException saying that the access to path is denied. The filePath value is
/storage/6133:6330/Download/demo.apk
Any heads up on how to solve this issue? Is it because of the FileStream or is it because of my plugin? Thanks in advance.
Answer by visbit-inc · May 11, 2020 at 08:02 AM
Unlike the internal SDcard folder, you are not allowed to save to any folder on the removable SD card other than the folder that specifically for your own app, which is in the form of something like /storage/6133:6330/Android/data/Your_app_bundle_id/files
This is the restriction of the C# runtime, not by the Android system. You can still access to the removable SD card if using native plugins.
Your answer
![](https://koobas.hobune.stream/wayback/20220612133913im_/https://answers.unity.com/themes/thub/images/avi.jpg)