Removing records in the middle of the file

I have a binary file which contains a number of records. What is the best way to remove a record in the middle of the file?
Eg:
record 1 - record 2 - record 3 - record 4 - record 5
After removing, we get:
record 1 - record 3 - record 4 - record 5
One way to it is copy the remaining records to a new file, delete the old and rename the new file.
However when you have to do it frequently with large files that can be quite time consuming.

Another way is to add a bool variable called active to the record and set it to false when you want to delete it. It works well with big files and an additional benefit is that you can restore it if neccessary.
Topic archived. No new replies allowed.