On Windows Vista and higher, writing to the Program Files directory requires administrative privileges. Your file is probably being affected by virtualization (a redirection of the write operation) to the virtual store. You can find it (in Windows 7) in C:\Users\<username>\AppData\Local\VirtualStore
.
The obvious solution is not to try to save the settings in the wrong location in the first place. Your app should create a folder under %APPDATA%
, and write it's settings there instead. This answer to a related question can provide some links that might help.