I looked through another question asked here to get the code I tried.
So I have a dictionary here :
private static Dictionary<int, string> employees = new Dictionary<int, string>();
//the int key is for the id code, the string is for the name
Suppose the dictionary is filled with employees with names and an identification code
and so I tried this to 'save it' using a binary file :
FileStream binaryfile = new FileStream(@"..\..\data\employees.bin", FileMode.OpenOrCreate);
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(@"..\..\data\employees.bin", employees);
binaryfile.Close();
however, it seems this technique only works for objects.
here is the error that I get:
The best overloaded method match for 'System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(System.IO.Stream, object)' has some invalid arguments
my goal is to simply retrieve the saved dictionary by reading the binary file. (if that is even possible?)