Hello, I’m trying to have Unity, through script, create a file (or overwrite one that is already there) in the “Application.persistentDataPath”.
When I try to delete or overwrite a file, I get
"UnauthorizedAccessException: Access to path 'C:\Users\[user]\AppData\LocalLow\DefaultCompany\[project]\Temp\' is denied"
In case you’re wondering what I’m doing in code:
string appDataFilePath = Application.persistentDataPath + "/Temp/";
if (!Directory.Exists(appDataFilePath))
{
Directory.CreateDirectory(appDataFilePath);
}
UnityEditor.FileUtil.DeleteFileOrDirectory(appDataFilePath + "test.png");
I’ve gone to a lot of different questions and no one seems to be doing this much, but I still want to try to get this working, and I can’t get why access to this is denied. I don’t want to have to use admin privileges to be able to do it.
Maybe I’m doing this whole thing wrong and if there’s an easier way to do this, I’d love to try that too. Basically I’m trying to read the bytes from a PNG file and change and read them, and then save the edited png again in the appdata folder for later use.