I am creating a windows application, Where one reporting folder . I want when user setup my application user can set reporting folder location and that will also save in my app.config file . How can i do that ?
Asked
Active
Viewed 2,685 times
-2
-
You can use User Settings instead of saving values in the app.config file. See [Using Settings in C#](http://msdn.microsoft.com/en-us/library/aa730869%28v=vs.80%29.aspx) – Rui Jarimba Jun 03 '13 at 07:56
-
1please re-read your question before posting. whilst grammatical problems are forgiven in SO, your question here is far from understandable – Krishna Jun 03 '13 at 07:57
-
If you mean during installation see [this other question](http://stackoverflow.com/q/3925216/447356) then use Neil answer here to store the path. – Shadow The GPT Wizard Jun 03 '13 at 08:04
1 Answers
1
To modify the Application.exe.config
you need to use ConfigurationManager
class.
Here is a code sample:
// Open App.Config of executable
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Add an Application Setting.
config.AppSettings.Settings.Remove("UserReportPath");
config.AppSettings.Settings.Add("UserReportPath", txtUserReportPath.Text);
// Save the configuration file.
config.Save(ConfigurationSaveMode.Modified);
// Force a reload of a changed section.
ConfigurationManager.RefreshSection("appSettings");

Neil Knight
- 47,437
- 25
- 129
- 188
-
@Neli Knight
this is one of my report path . I want when user setup they can choose a path and that will save here ? – A.Goutam Jun 03 '13 at 08:05