- Home /
Write Access
I have been trying to gain write access in the Application.dataPath which leads to Program Files(x86) in my case. I have tried to obtain this through batch files etc. The log files isn't created and I get this on startup:
UnauthorizedAccessException: Access to the path 'C:/Program Files (x86)/Game/Game_Data/../' is denied.
is the game open? Close it and try again. Or do you have $$anonymous$$cAfee
I do not have $$anonymous$$cAffee, I have already tried to restart the game with no results and yes the game is open when this error is printed.
then close the game. I dont write to it when you have it open..
Answer by einWikinger · Feb 15, 2015 at 07:52 AM
Short Answer: You can't. Windows changed the default permissions for the programs folder to be writeable by administrator users only. That's why all setups require UAC permission to elevate to admin privileges to be able to copy application files there. If you have to write to the path, you either have to:
Change the write permissions in your setup
Run your application with administrator privileges
Manually change the write permissions of the directory
Anyways, I'd advise to write log files and other dynamic data to the user path, not the application path, which is inside the current users appdata directory
http://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html
You're guranteed to have write permission there!