public TwitchCredentialsWindow() { InitializeComponent(); this.labelNM1.Text = GlobalVariables.TagName; this.FormClosing += FormclosingCallback; this.pictureBoxNM1.SendToBack(); this.FormBorderStyle = FormBorderStyle.None; this.DoubleBuffered = true; this.SetStyle(ControlStyles.ResizeRedraw, true); TwitchCredentials cred = new TwitchCredentials(); string path = Path.Combine(Properties.Settings.Default.path, SETTINGS_NAME2); if (File.Exists(path)) { cred = JsonConvert.DeserializeObject <TwitchCredentials>(File.ReadAllText(path)); } else { path = Path.Combine(Properties.Settings.Default.path, SETTINGS_NAME1); if (File.Exists(path)) { cred = JsonConvert.DeserializeObject <TwitchCredentials>(File.ReadAllText(path)); } } if (cred != null) { this.textBox1.Text = cred.Channel; this.textBox2.Text = cred.Username; this.textBox3.Text = cred.OauthKey; } }
private void Save() { TwitchCredentials cred = new TwitchCredentials(); cred.Channel = this.textBox1.Text; cred.Username = this.textBox2.Text; cred.OauthKey = this.textBox3.Text; string path = Path.Combine(Properties.Settings.Default.path, SETTINGS_NAME2); if (File.Exists(path)) { File.WriteAllText(path, cred.SerializeToJSON()); } else { path = Path.Combine(Properties.Settings.Default.path, SETTINGS_NAME1); if (File.Exists(path)) { File.WriteAllText(path, cred.SerializeToJSON()); } } }