currently having an issue with individual files being selected via an 'openFileInput'. The idea is that a user selects between 1-5 docs using the open-file, the combine button then merges these into one document depending on the user output folder selection.
private string[] selectedDocs;
string selectedFile1 = @"";
private void browseFileButton1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileInput1 = new OpenFileDialog();
openFileInput1.Filter = "Word Documents|*.docx;*.doc";
openFileInput1.Title = "Select a Word Document";
openFileInput1.FileName = selectedFile1;
filePath1.Text = openFileInput1.FileName;
if (openFileInput1.ShowDialog() == DialogResult.OK)
{
selectedFile1 = openFileInput1.FileName;
filePath1.Text = openFileInput1.FileName;
}
}
private string outputFolder2 = @"";
private void browseButtonOut2_Click(object sender, EventArgs e)
{
FolderBrowserDialog diagBrowserOutput2 = new FolderBrowserDialog();
diagBrowserOutput2.Description = "Select a folder location to save the document...";
diagBrowserOutput2.SelectedPath = outputFolder2;
outputPath2.Text = diagBrowserOutput2.SelectedPath;
if (DialogResult.OK == diagBrowserOutput2.ShowDialog())
{
outputFolder2 = diagBrowserOutput2.SelectedPath;
outputPath2.Text = diagBrowserOutput2.SelectedPath;
}
}
private void combineButton2_Click(object sender, EventArgs e)
{
string mixedFolder = Path.Combine(selectedFile1, selectedFile2, selectedFile3, selectedFile4, selectedFile5);
selectedDocs = Directory.GetFiles(mixedFolder, "*.doc");
string outcomeFolder2 = outputFolder2;
string outputFile2 = "Combined-files.docx";
string outputFileName2 = Path.Combine(outcomeFolder2, outputFile2);
MsWord.Merge(selectedDocs, outputFileName2, true);
}
i currently having this working if the user selects a folder containing a list of documents, however i'm trying to enable this to work with individual file selection as opposed to folder selection. The issue seems to be flagged up here,
selectedDocs = Directory.GetFiles(mixedFolder, "*.doc");
any advice or suggestions are welcomed, thank you
What I have tried:
combining the list of individual user selections into one path for merging