Hello,
Welcome to our Microsoft Q&A platform!
Do you get System.UnauthorizedAccessException?
If so, you did not grant the runtime write external permission. So you cannot create a directory without permission(your permission confirmation screen pop up, but you did not grand the permssion at this time).
So, please open your MainActivity.cs
, find the OnRequestPermissionsResult
method. using following code to check the write permission if granded. If granted, we can execute the start.
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
int WRITE_EXTERNAL_STORAGE=0;
if (requestCode == WRITE_EXTERNAL_STORAGE)
{
for (int i = 0; i < permissions.Length; i++)
{
if (permissions[i] == "android.permission.WRITE_EXTERNAL_STORAGE" && grantResults[i] == Permission.Granted)
{
Start();
}
else
{
Log.Info("TAG", "WRITE_EXTERNAL_STORAGE permission was NOT granted.");
}
}
}
else
{
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.