/// <summary> /// Serializes the action objects to a file located at the given path /// </summary> /// <param name="actions">The list of actions you want serialized</param> /// <param name="pathToFile">The path to the file that will contain the serialized action objects</param> /// <returns>True if succesfull, false if not</returns> public static bool Serialize(List <Action> actions, string pathToFile) { // Create a hashtable of values that will eventually be serialized. Hashtable hashActions = new Hashtable(); foreach (Action a in actions) { hashActions.Add(a.ID, a); } // To serialize the hashtable and its key/value pairs, // you must first open a stream for writing. // In this case, use a file stream. FileStream fs = new FileStream(pathToFile, FileMode.Create); // Construct a BinaryFormatter and use it to serialize the data to the stream. BinaryFormatter formatter = new BinaryFormatter(); try { formatter.Serialize(fs, hashActions); } catch (SerializationException ex) { ErrorPopup p = new ErrorPopup(ex); p.Show(); return(false); } finally { fs.Close(); } return(true); }
private static void ShowError(Exception ex) { ErrorPopup pop = new ErrorPopup(ex); pop.Show(); }