public static Solution Load(string path) { Solution res = null; if (File.Exists(path)) { XmlSerializer ser = new XmlSerializer(typeof(Solution)); using (StreamReader sr = new StreamReader(path)) { try { res = (Solution)ser.Deserialize(sr); res.FullPath = path; res.name = System.IO.Path.GetFileNameWithoutExtension(res.FullPath); } catch(Exception ex) { MessageBox.Show("This is not a valid solution file. Error details:\n" + ex.Message, "Cinar Database Tools", MessageBoxButtons.OK, MessageBoxIcon.Error); res = new Solution(); res.FullPath = path; res.name = System.IO.Path.GetFileNameWithoutExtension(res.FullPath); } } } else { MessageBox.Show("File not found:\n" + path, "Cinar Database Tools", MessageBoxButtons.OK, MessageBoxIcon.Error); } return res; }
private void cmdNewCinarSolution(string arg) { if (Solution != null && Solution.Modified) { DialogResult dr = MessageBox.Show("Would you like to save current project: \n\n" + Solution.FullPath, "Cinar Database Tools", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.Yes) Solution.Save(); else if (dr == DialogResult.Cancel) return; } FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Select root folder for the new solution"; if (fbd.ShowDialog() == DialogResult.OK) { Solution s = new Solution(); s.Name = Path.GetFileNameWithoutExtension(fbd.SelectedPath); s.FullPath = fbd.SelectedPath + "\\" + s.Name + ".cgs"; s.Save(); openProject(s.FullPath); } }