Re: Adding/Removing byes from the beginning of a file
- Posted by DerekParnell (admin) Feb 21, 2015
- 1768 views
GreenEuphorian said...
How to add/remove bytes from the beginning of a (binary) file?
You have to create a new file based on copying the original file, adding bytes or not copying bytes as required.
Sorry but there is no easy way out of this. Doing low-level filesystem manipulation is bound to be messy and dangerous; definitely not worth the effort.
If running on Windows, you could open the file in update mode, copying bytes from later locations to earlier locations (means remembering and setting current file position) and then when you have finished that, calling the API routine SetEndOfFile() in the kernel.dll.