private bool Save() { // need to save file first then exit if (map.File == null) { if (!SaveAs()) { return(false); } } string file = map.File; StreamWriter writer = null; bool bOK = true; try { writer = new StreamWriter(file); writer.Write(map.MapSource); map.Modified = false; map.ClearUndo(); SetTitle(false); } catch (Exception ae) { bOK = false; MessageBox.Show(ae.Message + "\r\n" + ae.StackTrace); } finally { writer.Close(); } if (bOK) { this.map.Modified = false; } return(bOK); }