0
When I run the APP and at the time of reading and downloading a PDF file, I get the error of:
corrupted or missing file.
I know that Android 11(API 30) has problems with external files.
This is my code:
[Obsolete]
    public async Task<string> SaveFileToDisk(string fileName, byte[] bytes)
    { 
    if (!Directory.Exists(_rootDir))
        Directory.CreateDirectory(_rootDir);
    var filePath = Path.Combine(_rootDir, fileName);
    File.WriteAllBytes(filePath, bytes);
    return filePath;
}
When I come to this line Directory.CreateDirectory(_rootDir); the application generates the above mentioned error.
The file exists (PDF) and in previous versions runs well. I know that Android 11 has problems with Read/Write in external directories. I cleared the permits: Readexternalstorage, Writeexternalstorage, Manageexternalstorage.
And yet I still keep catching these mistakes.
How do I fix it?