I am trying to change the values of certain appSettings entries in app.config. I think I've got everything right but I can't seem to write to the file. I'm thinking it's a permissions issue, and wondering exactly what user is writing to the file, when the executable attempts a write.
public partial class Credentials : Form
{
public Credentials()
{
InitializeComponent();
byte[] userNameBytes = Convert.FromBase64String(Properties.Settings.Default.UserName);
byte[] passwordBytes = Convert.FromBase64String(Properties.Settings.Default.Password);
textUserName.Text = Encoding.UTF8.GetString(userNameBytes);
textPassword.Text = Encoding.UTF8.GetString(passwordBytes);
}
private void btnSave_Click(object sender, EventArgs e)
{
byte[] userNameBytes = Encoding.UTF8.GetBytes(textUserName.Text);
byte[] passwordBytes = Encoding.UTF8.GetBytes(textPassword.Text);
Properties.Settings.Default.UserName = Convert.ToBase64String(userNameBytes);
Properties.Settings.Default.Password = Convert.ToBase64String(passwordBytes);
Properties.Settings.Default.Save();
Close();
}
}