I recently came across a write permission error when backing up the database master key encryption to a file. I was running SSMS as the Administrator and executed below SQL statement:
BACKUP master key to file = N'\\SharedFolder\Keys\database_DEV_master.key'
PASSWORD = N'SupperStrongPassword$$$'
However the below error occurred:
[Cannot write into file '\\SharedFolder\Keys\database_DEV_master.key'.
Verify that you have write permissions, that the file path is valid,
and that the file does not already exist.]
The error looked obvious but it took me a while to recognize that SSMS was using SQL service account to execute SQL statement.
To fix the problem, I gave SQL service account "write" permission to the network shared folder and re-ran the SQL statement.