-1

I have a list of objects which I'd like to save to disk when ever an item is changed.

One option is to serialize the whole list but given there will be thousands of entities it seems like a bit of a waste to write the whole thing to disk again.

Is there a way to update the serialised file with just the data that's changed and not have to serialize the whole thing each time one entity is changed?

Nick
  • 193
  • 9
  • 2
    Use a database.. *Is there a way* - yes, but it'll be so complex arranging all the IO that you'll practically end up writing a database. That wheel is already invented; SQLite is a nice, powerful, small, file based database. Take a look at an Entity Framework/SQLite tutorial; it'll take less than an hour to get up and running. Or sack it off and take the simple route; periodically overwrite the file on disk with the complete new result of ser'ing the list (BSON?). Your SSD can write hundreds of megabytes a second. it won't even blink at the task of saving thousands of list entries – Caius Jard May 22 '22 at 18:10
  • 1
    Have you considered using a data base instead of writing to disk with a flat file? Using a data base should allow you to update individual records. – JohnG May 22 '22 at 18:11

0 Answers0