public static ApplicationSettings Load(string pConfigFilePath) { ApplicationSettings tSettings = new ApplicationSettings(); StreamReader tReader = null; if (File.Exists(pConfigFilePath)) { try { XmlSerializer tSerializer = new XmlSerializer(typeof(ApplicationSettings)); tReader = new StreamReader(pConfigFilePath); tSettings = (ApplicationSettings)tSerializer.Deserialize(tReader); } catch { throw new Exception(pConfigFilePath + " - could not be deserialized!"); } finally { if (null != tReader) { tReader.Close(); } } } else { tSettings.Save(pConfigFilePath); } Singleton = tSettings; return tSettings; }
public bool CreateDatabase() { string tFilename = ""; string tLastFolder = ""; // create a new blank database for our project SaveFileDialog tDlg = new SaveFileDialog(); tDlg.Filter = Resources.DB_Save_Dlg_Filter; tDlg.Title = Resources.DB_Save_Dlg_Title; tDlg.DefaultExt = ".db"; if (tDlg.ShowDialog() == DialogResult.OK) { if (tDlg.FileName != "") { // get the filename tFilename = tDlg.FileName; tLastFolder = Path.GetDirectoryName(tFilename); } } // FF store as infos ApplicationSettings tSettings = new ApplicationSettings(); tSettings.LastDBFileCreated = tFilename; tSettings.LastDBFolder = tLastFolder; tSettings.Save(ApplicationSettings.DefaultSaveFilePath()); // create database now return NewDatabase(tFilename); }