1. ConfigurationManager namespace: Using System.Configuration;
2. To is able to save you has to use a configuration object returned by the Openexeconfiguration Method
//Create The ObjectConfiguration config =configurationmanager.openexeconfiguration (configurationuserlevel.none);//Make changesConfig. appsettings.settings["Username"]. Value =Txtusername.text;config. appsettings.settings["Password"]. Value =txtPassword.Text;//save to apply ChangesCONFIG. Save (configurationsavemode.modified); Configurationmanager.refreshsection ("appSettings");
3. When you run the your application with F5,
- Your code is compiled,
bin
bin\Debug
The executable is copied to the or subdirectory of your source code directory,
- Your
app.config
yourexecutable.exe.config
is copied as to that directory, and
- Your executable is started in that directory.
Thus, your application uses the yourexecutable.exe.config
in the bin
or bin\debug
directory, and it is there that ConfigurationManager
saves The changes, not in your source code directory. This won ' t is a issue after deploying your application, because then, changes'll go to yourexecutable.exe.co Nfig
in The deployment directory, which is what you want.