I have to access the files on the external sd card, but I can't because an error is returned.
How can I activate the authorization to access the SD card?
My code:
private void Button_Clicked(object sender, EventArgs e)
{
var filesPath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDocuments).Path;
var files = System.IO.Directory.GetFiles(filesPath);
}
The error is:
Access to the path '/ storage / emulated / 0 / Documents' is denied.
Have you requested the runtime permission?
Before 6.0, the permission system of Android was always used by users to request authorization from users during installation, so the app may obtain some private information without users' knowledge after installation.
In order to solve this problem, Google improved the permission system in Android 6.0, and changed some permissions related to users' privacy to request authorization from users dynamically when the app runs.
you could refer to RuntimePermission
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.