Configuration changes now saving properly.
This commit is contained in:
parent
0a132d75ec
commit
6d06fa90e5
1
ConfForm.Designer.cs
generated
1
ConfForm.Designer.cs
generated
@ -50,6 +50,7 @@ namespace PDF_Merge
|
||||
saveBtn.TabIndex = 0;
|
||||
saveBtn.Text = "Save";
|
||||
saveBtn.UseVisualStyleBackColor = true;
|
||||
saveBtn.Click += saveBtn_Click;
|
||||
//
|
||||
// cancelBtn
|
||||
//
|
||||
|
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user