System.UnauthorizedAccessException: Access to the path “/Download” is denied. in xamarin android

I am trying to generate PDF from byte array. but it's giving issue "access path is denied". I have already given the permission in manifest file. I am sending my code block please check it for a minute and give some suggestion and feedback so that i can complete it.


  • Code Block

    private void ObjbtnViewSlip_Click(object sender, EventArgs e)
    var result = objPaySlipViewModel.GetPaySlipByte(GlobalApplicationSession.EmployeeCode, GlobalApplicationSession.CompanyId, selectedPeriod);
    if (File.Exists(Android.OS.Environment.DirectoryDownloads + "/RSI/PaySlip/temp.pdf") == false)
    Directory.CreateDirectory(Android.OS.Environment.DirectoryDownloads + "/RSI/PaySlip/");
    File.Create(Android.OS.Environment.DirectoryDownloads + "/RSI/PaySlip/temp.pdf");
    System.IO.File.WriteAllBytes(Android.OS.Environment.DirectoryDownloads + "/RSI/PaySlip/", result);

Sign In or Register to comment.