public static String GetManticorePath(String aPath) { String path = ""; String appData = ""; switch (aPath) { case "AppData": path = FileLocator.GetFolderPath(FileLocator.SpecialFolders.ssfAPPDATA); path += @"\Manticore\"; break; case "UserPrefs": appData = FileLocator.GetManticorePath("AppData"); path += appData + @"user-prefs.xml"; break; case "LocalBookmarks": appData = FileLocator.GetManticorePath("AppData"); if (appData != "") { path += appData + @"bookmarks.xml"; } break; case "Application": path = Application.ExecutablePath; int lastSlash = path.LastIndexOf(@"\"); path = path.Substring(0, lastSlash + 1); break; } return(path); }
public void LoadUserPreferences() { String manticoreAppData = FileLocator.GetManticorePath("AppData"); String prefPath = FileLocator.GetManticorePath("UserPrefs"); try { LoadPreferencesFile(prefPath); } catch (XmlException) { // Something went wrong, we'll just assume a malformed or non-existant // preferences file, blow it away and insert a new one. Could potentially // be dangerous. try { File.Copy(@"defaults\user-prefs.xml", prefPath, true); } catch (DirectoryNotFoundException) { Directory.CreateDirectory(manticoreAppData); File.Copy(@"defaults\user-prefs.xml", prefPath, true); } LoadPreferencesFile(prefPath); } }
public void FlushUserPreferences() { FlushPreferencesFile(FileLocator.GetManticorePath("UserPrefs")); }