I need to open a file, deserialize a List<> of objects, remove one of the objects from the list and re-serialize the List<> back to the file without releasing a lock on the file.
Deserialization and removal of the object from the List<> is no problem, the problem comes when I try and serialize the List<> back to the file as I get the remains of the previous data… anybody any idea how to remove the remaining old data at the end of the file?
Thanks,
Paul.
I assume that you open the file with read/write access, and that you keep it open between deserialization and serialization ? You need to :
UPDATE:
Good point… in that case you could try to truncate the stream while it is open, using SetLength :
(not tested)