public static ETS2SyncConfig LoadConfig(String assemblyPath, Boolean UseSettingsDir) { //ILog lg = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); string pd = assemblyPath; if (UseSettingsDir) { pd = System.IO.Path.Combine(pd, "Settings"); } string fn = System.IO.Path.Combine(pd, "Settings.xml"); //lg.Debug(String.Format("Using Path:'{0}'", fn)); ETS2SyncConfig cfg; try { if (File.Exists(fn)) { ConfigXmlFile cxf = new ConfigXmlFile(fn, true); cfg = cxf.Get <ETS2SyncConfig>(); } else { cfg = new ETS2SyncConfig(); ETS2SyncConfig.SaveConfig(Functions.GetAssemblyDirectory(), cfg); } } catch (Exception e) { cfg = new ETS2SyncConfig(); } return(cfg); }
public static void SaveConfig(String assemblyPath, ETS2SyncConfig cfg, Boolean UseSettingsDir) { string pd = assemblyPath; if (UseSettingsDir) { pd = System.IO.Path.Combine(pd, "Settings"); if (!Directory.Exists(pd)) { Directory.CreateDirectory(pd); } } string fn = System.IO.Path.Combine(pd, "Settings.xml"); ConfigXmlFile cxf = new ConfigXmlFile(fn, false); cxf.Save(cfg); }
public static void SaveConfig(string assemblyPath, ETS2SyncConfig cfg) { SaveConfig(assemblyPath, cfg, true); }
private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { ETS2SyncConfig.SaveConfig(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Rn.Config); }