Save data from LIST to 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.
-
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
user1410644
Updated on June 04, 2022Comments
-
user1410644 over 1 year
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?
-
user1410644 about 11 yearsI've already tried with something like this, but it doesn't work. I'm getting just "GlobalMacroRecorder.MacroEvent" in the text file. Thanks for the answer anyway :)
-
user1410644 about 11 yearsThe BinarySerializer is perfect. Thanks!