Question

With a Windows Forms (or WPF) application, if I create an installer through Publish command (ClickOnce that is), the installer creates application folder with executable and config file in C:\Users\[UserName]\AppData\. On the other hand, if the installer is created through Setup project (MSI), the installed app would be in C:\Program Files\My Company\My App with both the executable and the config file. Out of the two, I chose MSI path.

My expectation was that the application settings (as in Project properties > Settings tab) are read from/written to the config file that is in Program Files, which remains there even if I uninstall the program or upgrade it with a newer version, so that user's settings don't get lost. But it doesn't appear to be the case. Even that the Program Files version of the config file is there, the installed application appears to be reading from/writing to C:\Users\[UserName]\AppData\ as if it were a ClickOnce app. What am I missing?

(This is VS2010 + Win7 + C# + .NET 4.0 Client Profile, though I don't think those things have anything to do).

Was it helpful?

Solution

I hope I understand your question in the right way.

If you want to know, why settings are read from/written to the AppData folder, then it's because of security/permission reasons.

When first starting your application, your initially application settings from app.config file were copied to that folder. Your application will automatically work on that newly created file.

This is done, because it's a risk letting the user work on the "global" settings in your Program Files folder, with which all your users will work. Think about what would happen, if a user only has permissions to read, but not to write to this file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top