private void createXMLToolStripMenuItem_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); DialogResult result = fbd.ShowDialog(); if (result == DialogResult.OK) { DirectoryInfo dir = new DirectoryInfo(fbd.SelectedPath); var element = new XDocument(xmlHelper.CreateAndSaveXml(dir)); SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "XML file | *.xml"; if (sfd.ShowDialog() == DialogResult.OK) { element.Save(Path.GetFullPath(sfd.FileName)); DialogResult msgResult = MessageBox.Show("XML Successfully Saved at \n" + Path.GetFullPath(sfd.FileName), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }