public void LoadConfiguration() { if (File.Exists("config.xml")) { XmlSerializer xmlSr = new XmlSerializer(typeof(ConfigurationData)); FileStream readStream = new FileStream("config.xml", FileMode.Open, FileAccess.Read, FileShare.Read); ConfigurationData config = (ConfigurationData)xmlSr.Deserialize(readStream); txtUsername.Text = config.username; CryptoService.EncryptedBundle eb = new CryptoService.EncryptedBundle(); eb.EncryptedString = config.password; eb.EncryptedKey = config.key; txtPassword.Text = CryptoService.DecryptString(eb, "s8Jkd74hHdyrO9h6"); txtClearpassStartPageUrl.Text = config.startPage; chkEnableLogging.Checked = config.enableLogging; txtLogPath.Text = config.logPath; readStream.Close(); } }
public void SaveConfiguration() { try { ConfigurationData config = new ConfigurationData(); config.username = txtUsername.Text; CryptoService.EncryptedBundle eb = new CryptoService.EncryptedBundle(); eb = CryptoService.EncryptString(txtPassword.Text, 20, "s8Jkd74hHdyrO9h6"); config.password = eb.EncryptedString; config.key = eb.EncryptedKey; config.startPage = txtClearpassStartPageUrl.Text; config.enableLogging = chkEnableLogging.Checked; config.logPath = txtLogPath.Text; WriteXMLData.SaveData(config, "config.xml"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }