I’m using this library http://www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library to record a macro.
I want to know how to save the “events” in a text file to load them later?
So, here is the LIST:
List<MacroEvent> events = new List<MacroEvent>();
What I need to do to get the data into a text file?
You have 3 options:
Use the ToString() method in order to export the MacroEvent to a formatted text. You probably need to override the default implementation. Make sure to put all the information you need, otherwise you won’t be able to retrieve them later. Reading and parsing the file is then needed to load the data.
Use the builtin .net XML serialization feature. Write/Read operation is straightforward.
http://msdn.microsoft.com/en-us/library/ms950721.aspx
http://support.microsoft.com/kb/815813
If you are not planning on using the data on another application, why not use the BinarySerializer? By far, the best method, but the resulting file won’t be in text format.
http://www.codeproject.com/Articles/1789/Object-Serialization-using-C