public void LoadConfig() { LauncherSettingsFile sfile = new LauncherSettingsFile(); try { sfile.ReadFromFile(Engine.SETTINGS_PATH); spGamePath.Text = sfile.ExecutablePath ?? Resource.Strings.EmptyPath; ofdGamePath.InitialDirectory = Path.GetDirectoryName(sfile.ExecutablePath); } catch { spGamePath.Text = Resource.Strings.EmptyPath; } }
public static MountResult CreateFromConfig(string configPath, out MountInfo mount) { mount = null; if (!File.Exists(configPath)) { return(new MountResult(MountErrorType.CONFIG_NOTFOUND, Resource.Strings.MountError_CONFIG_NOTFOUND.F(configPath))); } LauncherSettingsFile sFile = new LauncherSettingsFile(); try { sFile.ReadFromFile(configPath); } catch (Exception ex) { return(new MountResult(MountErrorType.CONFIG_READ_ERROR, Resource.Strings.MountError_CONFIG_READ_ERROR, ex)); } return(Create(sFile.ExecutablePath, out mount)); }
public bool WriteConfig() { LauncherSettingsFile sfile = new LauncherSettingsFile(); // We read the existing file, if any. This allows settings beyond the scope of this screen to be saved try { sfile.ReadFromFile(Engine.SETTINGS_PATH); } catch { } if (spGamePath.Text != Resource.Strings.EmptyPath) { sfile.ExecutablePath = spGamePath.Text; } // Save try { sfile.WriteToFile(Engine.SETTINGS_PATH); } catch (Exception ex) { SaveError?.Invoke(Resource.Strings.Error_WriteConfig.F(ex.Message), ex); return(false); } return(true); }