private void button1_Click(object sender, EventArgs e) { List <SettingsModel> models = new List <SettingsModel>(); for (int i = 1; i <= 5; i++) { Dictionary <string, string> parameters = new Dictionary <string, string>(); var tbxfolderName = this.Controls.Find($"{SUBFOLDER_CONTROL_NAME}{i}", true)[0] as TextBox; if (tbxfolderName != null) { parameters.Add(IniData.FOLDER_NAME_KEY, tbxfolderName.Text); } var tbxfolderFormats = this.Controls.Find($"{SUBFOLDER_CONTROL_FORMATS}{i}", true)[0] as TextBox; if (tbxfolderFormats != null) { parameters.Add(IniData.FORMAT_KEY, tbxfolderFormats.Text); } SettingsModel model = new SettingsModel($"Folder{i}", parameters); models.Add(model); } if (!string.IsNullOrEmpty(btnFolder.Text)) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add(IniData.WATCHED_FOLDER_KEY, btnFolder.Text); models.Add(new SettingsModel(IniData.GLOBAL_SETTINGS, parameters)); } IniData.Save(models); ServiceManager.Start(); }