private void btnGenerateForest_Click(object sender, EventArgs e) { var fs = GetForestSpecification(); if (fs == null) { return; } forest = ForestGenerator.Generate(fs, "^"); var sfd = new SaveFileDialog { Filter = "txt files (*.txt)|*.txt", FileName = "forest.txt" }; if (sfd.ShowDialog() != DialogResult.OK) { return; } if (string.IsNullOrEmpty(sfd.FileName)) { return; } ForestGenerator.SaveForestToFile(forest, sfd.FileName, false); }