/// <summary> /// Saves a bots EPROM to disk /// </summary> /// <param name="botID">The Guid of the bot</param> /// <param name="botROM">The bots EPROM object to save</param> /// <returns>Success or Failure</returns> internal static bool SaveROM(Guid botID, EPROM botROM) { try { using (FileStream fs = new FileStream(Consts.FileLocation + botID.ToString() + Consts.EPROMExtenstion, FileMode.Create)) { binaryFormatter.Serialize(fs, botROM); } return(true); } catch (Exception) { return(false); } }
/// <summary> /// Loads a bot EPROM from disk /// </summary> /// <param name="botID">The Guid of the bot</param> /// <returns>The EPROM object</returns> internal static EPROM LoadROM(Guid botID) { if (!File.Exists(Consts.FileLocation + botID.ToString() + Consts.EPROMExtenstion)) { return(null); } EPROM rom = null; using (FileStream fs = new FileStream(Consts.FileLocation + botID.ToString() + Consts.EPROMExtenstion, FileMode.Open)) { if (fs.Length > 0) { rom = binaryFormatter.Deserialize(fs) as EPROM; } } return(rom); }