Quote:
so again StreamReader reads a text file and then edits it like like MessageBox?
No ... a StreamReader does what it says: reads a file from the beginning to the end.
And the problem you have is that text files have no organization: you can't insert text into the middle of a text file, you have to create a new file, copy everything up to the insertion point from the old to the new, write your new data, then copy everything else from the old file into the new, close them both, delete the original, and rename the new file.
And given that you don't know where in the file your data will be ... or how long your entries are ... it's going to be difficult to do that. To make things worse, your time - the data you want to sort on - is now a string, so it will get organized by the string sort order not a time-based one.
The way I'd do it is to store it in a less human readable form: create a class that holds the duration, the example number, and the duration as native numeric values rather than strings. Then I'd create a List of that class, and read / write it to the file via JSON.
Nobody is going to look at the file anyway, and it's a lot easier to sort / search / filter the data if it's in numeric based values rather than mixed into a string somewhere in a text file!
Sounds complicated? It isn;t, not really - reading and writing a whole List<MyClass> to / from a JSON file is one line of code!