I have a BinaryReader/BinaryWriter with a length of 1000 bytes, each record is 50 bytes. How can I eliminate the records at position 350 to 550 and in the end keep the remaining 800 bytes in my file?
I have a BinaryReader/BinaryWriter with a length of 1000 bytes, each record is 50
Share
The simplest way would be to loop through the records, reading from one file and writing to a new one, and eliminating the records you don’t need.
In theory you could seek within the same file, overwriting the “old” data with new data, but I’d personally go for a simple approach where possible. It also means that if anything fails half way through, you’ve still got the original file and a “bad” file which can just be deleted, rather than a file which may contain some records twice.