How to create Filestream in macOS Catalina?

My application maintains a folder list to automatically save some files to users such as application logs, reports, PDFs, backups, etc.

Until High Sierra I could save the files automatically, but in Catalina whenever I try to generate any file I get the error message "Cannot create file “...”. Operation not permited".

However, if before creating the file I execute FMX.Dialogs.SelectDirectory(), I can create the files in the selected folder until the user finishes the application.

The next time the application is run the error reoccurs until FMX.Dialogs.SelectDirectory() is executed again.

I tried to enable full application access to disk (in macOS), but the issue was not resolved.

Does anyone know how to solve this problem?

I am using Delphi 10.3.3 and the save routine I use is very simple:


var
   wWork: String;
   wOutput: TFileStream;
begin
  wWork:=IncludeTrailingPathDelimiter(wPath)+ 'Backup.DMP';
  wOutput:=TFileStream.Create(wWork, fmCreate);
  Try
    wOutput.Write(...)
   wOutput.Write(...)
  Finally
    wOutput.Free;
  End;
End;