static public void LoadConfig(string file_path, List <ConfigConectUI> config_conect_ui) { System.IO.StreamReader file = new System.IO.StreamReader(file_path); List <KeyValuePair <string, string> > key_list = LoadAssist(file); file.Close(); foreach (KeyValuePair <string, string> i in key_list) { foreach (ConfigConectUI c in config_conect_ui) { if (i.Key == c.key) { if (c.control is ComboBox) { ((ComboBox)c.control).Text = i.Value; } else if (c.control is TextBox) { ((TextBox)c.control).Text = i.Value; } else if (c.control is CheckBox) { ((CheckBox)c.control).Checked = i.Value == "True"; } else if (c.control is RichTextBox) { ((CheckBox)c.control).Text = CommonStringBase64.ToUTF8(i.Value); } } } } }
static public void SaveConfig(string file_path, List <ConfigConectUI> config_conect_ui) { //ファイルを上書きし、UTF-8で書き込む System.IO.StreamWriter sw = new System.IO.StreamWriter( file_path, false, System.Text.Encoding.GetEncoding("UTF-8")); foreach (ConfigConectUI c in config_conect_ui) { if (c.control is ComboBox) { sw.WriteLine(c.key + " " + ((ComboBox)c.control).Text); } else if (c.control is TextBox) { sw.WriteLine(c.key + " " + ((TextBox)c.control).Text); } else if (c.control is CheckBox) { sw.WriteLine(c.key + " " + ((CheckBox)c.control).Checked); } else if (c.control is RichTextBox) { sw.WriteLine(c.key + " " + CommonStringBase64.ToBase64(((RichTextBox)c.control).Text)); } } //閉じる sw.Close(); }