Update code to reflect change in config file.

The configuration now seperates the output path and filename into
seperate componentants.
This commit is contained in:
2024-08-05 14:32:13 -04:00
parent f85361ed27
commit 1d332927d6
5 changed files with 56 additions and 7 deletions

View File

@@ -19,9 +19,11 @@ namespace PDF_Merge
string sourcePath = ConfigurationManager.AppSettings["PDF-Path"];
string outputPath = ConfigurationManager.AppSettings["PDF-Output"];
string outputName = ConfigurationManager.AppSettings["PDF-Name"];
sourceBox.Text = sourcePath;
outputBox.Text = outputPath;
FileNameBox.Text = outputName;
if (ConfigurationManager.AppSettings["overwrite"] == true.ToString())
{
overrideCBox.Checked = true;
@@ -57,6 +59,14 @@ namespace PDF_Merge
{
MessageBox.Show("Output path cannot be empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (FileNameBox.Text.Length > 0)
{
appSettings.Settings["PDF-Name"].Value = FileNameBox.Text;
}
else
{
MessageBox.Show("File must be named.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
appSettings.Settings["overwrite"].Value = overrideCBox.Checked.ToString();
appConfig.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
@@ -67,12 +77,26 @@ namespace PDF_Merge
{
using (var SourceDirPicker = new FolderBrowserDialog())
{
if(SourceDirPicker.ShowDialog() == DialogResult.OK)
if (sourceBox.Text == "")
{
SourceDirPicker.RootFolder = Environment.SpecialFolder.MyDocuments;
}
else
{
string startingDir = sourceBox.Text;
SourceDirPicker.SelectedPath = startingDir;
}
if (SourceDirPicker.ShowDialog() == DialogResult.OK)
{
var sourceDir = SourceDirPicker.SelectedPath;
sourceBox.Text = sourceDir;
}
}
}
private void outPathBtn_Click(object sender, EventArgs e)
{
using (var OutPathPicker = new OpenFileDialog()) { }
}
}
}