File IO...

02/11/2011 23:49 CptSky#1
What is the best way to delete some bytes that can be everywhere in a file?

Code:
FF FF 8F FF
By example, I want to delete the 8F... Sure, you can rewrite the file, but there is probably a better method...

In C/C++ or in C#...
02/12/2011 00:06 phize#2
I don't think there is any other way.

Read the file into a buffer byte per byte until you reach the offset then skip it and continue and overwrite the file with your buffer.
02/12/2011 04:38 shitboi#3
delete as in remove it from the file?

I may not be 100% correct on this, but ...

a file is an array of bytes, if you "delete" a byte, don't you need to shift the following bytes forward? that will suggest you re-writting the file. Even if there is a so called method/function to do it in one step, it probably has th re-writing part encapsulated.
02/13/2011 20:34 CptSky#4
If no specific method exist, I will write one myself, but like you said, I don't think there is an other way to delete a part of a file.