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.

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

You’re guranteed to have write permission there!