Configuration changes now saving properly.
This commit is contained in:
26
ConfForm.cs
26
ConfForm.cs
@@ -22,7 +22,7 @@ namespace PDF_Merge
|
||||
|
||||
sourceBox.Text = sourcePath;
|
||||
outputBox.Text = outputPath;
|
||||
if (ConfigurationManager.AppSettings["overwrite"] == "true")
|
||||
if (ConfigurationManager.AppSettings["overwrite"] == true.ToString())
|
||||
{
|
||||
overrideCBox.Checked = true;
|
||||
}
|
||||
@@ -36,5 +36,29 @@ namespace PDF_Merge
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void saveBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Configuration appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
AppSettingsSection appSettings = appConfig.AppSettings;
|
||||
if (sourceBox.Text.Length > 0)
|
||||
{
|
||||
appSettings.Settings["PDF-Path"].Value = sourceBox.Text;
|
||||
} else
|
||||
{
|
||||
MessageBox.Show("Source path cannot be empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if (outputBox.Text.Length > 0)
|
||||
{
|
||||
appSettings.Settings["PDF-Output"].Value = outputBox.Text;
|
||||
} else
|
||||
{
|
||||
MessageBox.Show("Output path cannot be empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
appSettings.Settings["overwrite"].Value = overrideCBox.Checked.ToString();
|
||||
appConfig.Save(ConfigurationSaveMode.Modified);
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user