I spend serialization in a binary, then this recorded data can be updated and you need to write about it in a binary. How can I find the desired entry and update? Through linq work? Or is it better to use serialization in xml for such purposes?

Thank!

Closed due to the fact that the essence of the issue is incomprehensible to the participants rjhdby , αλεχολυτ , Denis Bubnov , Vadim Ovchinnikov , fori1ton Jan 25 '17 at 9:09 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • You want to avoid the procedure: Deserialization of a binary to the collection -> Search the collection of the desired item -> Change the item -> Serialize to a binary file back. So? - Bulson
  • @Bulson of course, then it's easier for me, in my case, to just overwrite the file. - Valera Kvip
  • one
    VladD recommended creating a custom format with a fixed length ... already noted. Maybe still sqlite or mongodb? - Bulson
  • @Bulson, sqlite is already worth it, as I wanted to remove it, I want to save it, but I’ll probably leave it. - Valera Kvip

1 answer 1

Both serializations — that binary, that XML serialization — are strictly streaming. In them it is impossible to cleanly, without problems, find one necessary record and update it. Think about what happens if a new entry is shorter or longer than the old one?

If you want to update specific records, you should come up with your own format. For example, one in which the records have a fixed length in bytes (if possible).

Another option suggested in the comments is the database. However, the update in the database of one record may turn out to be slower than the complete rewriting of the file during binary serialization, so it makes sense to try both options for your particular data and compare.