nielscup / ShareFile

Share files with Xamarin.iOS, Xamarin.Android and Windows
MIT License
18 stars 7 forks source link

Access to the path "/storage/emulated/0...." is denied on Android #4

Closed PatrykZawieja closed 6 years ago

PatrykZawieja commented 6 years ago

I had problem: Access to the path "/storage/emulated/0...." is denied on Android (API Level 25). WRITE_EXTERNAL_STORAGE and READ_EXTERAL_STORAGE permissions doesn't help.

Finally i solved it changing a localFolder variable in method WriteFile in ShareFileImplementation class: var localFolder = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; to var localFolder = Android.App.Application.Context.GetExternalFilesDir(null).ToString();

nielscup commented 6 years ago

The problem is that your app needs to request for permission first. You can do this with this plugin. I have added this now to the Android test project as well.