With the latest Windows versions (at least for 7 and newer), Microsoft decided in their wisdom to make files in a directory in the "C:Program Files" or "C:Program Files (x86)" READ ONLY ... well, for those of us who'd like their program to be portable, this "feature" can be a real pain ...
How do we work around this limitation?
Option 1 - Write in the proper config directory ...
The function GetAppConfigDir(false); is helpful for that purpose and it works right out of the box ... well, kind-a anyway. The file is NOT stored with your application, which is something you'd like for an app that is suppose to be portable ... (pass the value false for apps)
Option 2 - Set the proper access rights ...
This method has worked for me so far, but I can't guarantee it to work for ever:
1 - Create a data directory in the application directory, for example:
C:Program Files<your application>data
2 - Right click and change the security settings.
For the group "Users" add the "Full Control" option. As of this point this file is read/write enabled for every user.
For distribution, we now zip the file with the data directory ... unzipping it on a different computer will bring along the access rights ,...