private void SaveUserPreferences() { UserPrefs prefs = new UserPrefs(); prefs.Server = txtServer.Text; prefs.ExportDirectory = txtExportRootDir.Text; UserPrefsRepository prefsRepository = new UserPrefsRepository(); prefsRepository.SaveUserPrefs(prefs); }
public virtual void SaveUserPrefs(UserPrefs prefs) { EnsureDirectoryExists(); try { using (StreamWriter sr = new StreamWriter(ConfigFilePath)) { serializer.Serialize(sr, prefs); } } catch (UnauthorizedAccessException) { } catch (SecurityException) { } }
private void LoadUserPreferences() { UserPrefsRepository prefsRepository = new UserPrefsRepository(); UserPrefs prefs = prefsRepository.LoadUserPrefs(); if (!string.IsNullOrEmpty(prefs.ExportDirectory)) { txtExportRootDir.Text = prefs.ExportDirectory; } else { txtExportRootDir.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } if (!string.IsNullOrEmpty(prefs.Server)) { txtServer.Text = prefs.Server; } else { txtServer.Text = Environment.MachineName; } }
private void SaveUserPreferences() { var prefs = new UserPrefs(); prefs.Server = txtServer.Text; prefs.ExportDirectory = txtExportRootDir.Text; _prefsRepository.SaveUserPrefs(prefs); }