private void ChooseTemplateBtn_Click(object sender, EventArgs e) { OpenTemplateDialog.ShowDialog(); try { textOperator.FileName = OpenTemplateDialog.FileName; textOperator.Doc = DocX.Load(OpenTemplateDialog.FileName); TemplateIsReady = true; } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void LoadTemplateLL_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { OpenTemplateDialog.Title = "Open an existing Scan Template"; while (OpenTemplateDialog.ShowDialog() == DialogResult.OK) { try { FileInfo OpenedFile = new FileInfo(OpenTemplateDialog.FileName); StreamReader Reader = new StreamReader(OpenedFile.FullName); string TemplateXml = Reader.ReadToEnd(); Reader.Close(); LoadSettingsFromTemplate(TemplateXml); ScanTemplateNameLbl.Text = string.Format("Loaded template file - {0}", OpenedFile.Name); break; } catch (Exception Exp) { MessageBox.Show(string.Format("Unable to open file: {0}", new object[] { Exp.Message })); } } }