private void _saveFileToolStripMenuItem_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(fileName)) { SerializeToXmlFile serialization = new SerializeToXmlFile(fileName); serialization.SerializeKnowledgeBase(knowledgeBase); } else { _saveAsFileToolStripMenuItem_Click(sender, e); } }
private void _saveAsFileToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog() { Title = "Zapisz plik", Filter = "Pliki tekstowe (xml)|*.xml", DefaultExt = ".xml", RestoreDirectory = true }; if (dialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(dialog.FileName)) { fileName = dialog.FileName; SerializeToXmlFile serialization = new SerializeToXmlFile(fileName); serialization.SerializeKnowledgeBase(knowledgeBase); MessageBox.Show("Zapisano bazę wiedzy do pliku:\n" + fileName, "Zapis bazy wiedzy"); } _filePathToolStripTextBox.Text = Path.GetFileName(fileName); }