1, define the configuration fields in the Settings.settings file. The scope is defined as: User can be changed while running, Applicatiion is not changed when run. Can use the data grid view, very convenient;2, read configuration value Text1.Text=Properties.Settings.Default.FieldName;//FieldName is the field you define3, modify, and save the configuration Properties.Settings.Default.FieldName="Server"; Properties.Settings.Default.Save ();//save changes using the Save method4, or you can create a configuration class ftpsetting yourself. In the WinForm application, all configuration classes inherit from the ApplicationSettingsBase class. Sealed classFtpsettings:applicationsettingsbase{[userscopedsetting][defaultsettingvalue ("127.0.0.1")] Public stringserver{Get{return(string) This["Server"]; }Set{ This["Server"] =value;}} [Userscopedsetting] [Defaultsettingvalue (" +")] Public intport{Get{return(int) This["Port"]; }Set{ This["Port"] =value;}}} Using the above configuration class, you can use:Private voidButton2_Click (Objectsender, EventArgs e) {ftpsettings FTP=Newftpsettings ();stringmsg = Ftp.server +":"+ftp.Port.ToString (); MessageBox.Show (msg);} When we use the above ftpsetting configuration, of course, we must first make the assignment to save, then use, then modify, then save, and then use. Private voidButton2_Click (Objectsender, EventArgs e) {ftpsettings FTP=Newftpsettings (); Ftp.server="ftp.test.com"; Ftp.port=8021; Ftp.save (); Ftp.reload ();stringmsg = Ftp.server +":"+ftp.Port.ToString (); MessageBox.Show (msg);} Well. Already saved, you may not be able to find where it is in the application folder. Since we are using Userscope, the configuration information is actually saved to your Windows personal folder. For example mine is C:\Documents and Settings\brooks\local Settings\Application Data\testwinform directory.
The role of setting.settings in WinForm in the development of VS C #