paul frith paul frith - 1 year ago 60 Question

Problems overwriting file in application folder

I have a file called

that sits in my application's root folder. My app loads this file into a text box, so that users can edit it and overwrite the original file by pressing a save button. This all worked perfectly during test, however after deployment users are unable to save the file due to write issues within
C:\Program Files

Is there a way around this - or is there a better way to implement this type of thing? One solution that springs to mind for me is placing the contents of the
file within a User Setting - however it intrinsically feels wrong to me to put the entire contents of a file within a settings variable.

Answer Source

Ordinary users do not have write permissions on %ProgramFiles%. If you need to save a configuration file then put it in a subfolder of %APPDATA% (which for me is C:\Users\Gord\AppData\Roaming) or some other place where a regular user is allowed to write.