public static void LoadMods() { List <IMod> mods = new List <IMod>(); FileInfo[] files = (new DirectoryInfo(ModConstants.MODS_LOCATION)).GetFiles("*.dll"); foreach (FileInfo file in files) { if (file.Name == ModConstants.MODLOADER_DLL_NAME) { continue; } try { mods.AddRange(LoadModsFromFile(file.FullName)); } catch (Exception e) { GeneralManager.Instance.LogToFileOrConsole("[PromDate] Failed to load in " + file.Name + " - Threw: " + e); } } if (!File.Exists(ModConstants.MODLOADER_PREFS_PATH)) { prefs = new ModPreferences(); } else { prefs = ModPreferences.Load(ModConstants.MODLOADER_PREFS_PATH); } _Mods.AddRange(mods); }
public static ModPreferences Load(string path) { BinaryFormatter bf = new BinaryFormatter(); FileStream f = File.Open(path, FileMode.Open); ModPreferences prefs = (ModPreferences)bf.Deserialize(f); f.Close(); return(prefs); }