I'm writing bytes to a random access file. After completing the operation, I want to delete the first 100 bytes from the file. How can I achieve this?
Thanks in advance.
I'm writing bytes to a random access file. After completing the operation, I want to delete the first 100 bytes from the file. How can I achieve this?
Thanks in advance.
AFAIK, you will need to copy the remaining bytes (file length - 100) to a new file. Deleting the first 100 bytes from a file is not possible without copying the remaining bytes to a new file.
Edit: As cdhowie rightly pointed out, you could:
Then repeat the process until the entire file is written. Finish off by setting the filelength 100 bytes less than previously. If you want to be on the safe side and not risk corrupting the original file, it could be worth writing to a temp file first.