Good Day!
I want to know if it's possible to show SaveFileDialogue
when saving .docx file using Novacode DocX
?
Sample:
string fileName = @"D:\Users\John\Documents\DocXExample.docx";
var doc = DocX.Create(fileName);
doc.InsertParagraph("This is my first paragraph");
doc.Save();
Where shoud I put the SaveFileDialogue
code?
Many Thanks!
Put saveFileDialog1.ShowDialog();
inside some button event handler which lets the user save the document. Double-click on the SaveFileDialog
icon in your Visual Studio designer window as well to add the FileOk event handler and within event handler, put your code like this:
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
{
var doc = DocX.Create(saveFileDialog1.FileName);
doc.InsertParagraph("This is my first paragraph");
doc.Save();
}
Hope it helps!