I’ve had this with both Android and iOS, and both have followed almost the same story. Previously working code started failing with UnauthorizedAccessException. No amount of reverting to previous commits, restarting, uninstalling/reinstalling, or trying on different devices has been able to get rid of it.
The code in question:
string filePath = Path.Combine(Application.persistentDataPath, "PerfReport.csv");
using (StreamWriter writer = new StreamWriter(filePath))
When it happened on Android, I had been writing to a subdirectory under persistentDataPath and was able to work around it by writing directly to persistentDataPath (no idea why that worked).
However, the same thing just happened on iOS, except that I’m already writing directly to persistentDataPath as you can see from the code above.
What can cause this?