Overwrite one section of binary file
-
Hi! I have a binary file that contains strings one after the other and I want to replace a string at offset x. The existing string is, let's say 10 bytes long, but the new one is 12 bytes long. How do I replace the old string at position x without overwriting the first 2 bytes of the next string and without rewriting the entire binary file from offset x. Thanks already in advance!
-
Hi! I have a binary file that contains strings one after the other and I want to replace a string at offset x. The existing string is, let's say 10 bytes long, but the new one is 12 bytes long. How do I replace the old string at position x without overwriting the first 2 bytes of the next string and without rewriting the entire binary file from offset x. Thanks already in advance!
-
Hi! I have a binary file that contains strings one after the other and I want to replace a string at offset x. The existing string is, let's say 10 bytes long, but the new one is 12 bytes long. How do I replace the old string at position x without overwriting the first 2 bytes of the next string and without rewriting the entire binary file from offset x. Thanks already in advance!
You can't. You MUST rewrite the entire file. Read the the part up to the point where you are replacing the string, write it to a new file. Append the new string, then read the file from the point after the string your replacing and append that to the new file. There is NO other way to do this. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
You can't. You MUST rewrite the entire file. Read the the part up to the point where you are replacing the string, write it to a new file. Append the new string, then read the file from the point after the string your replacing and append that to the new file. There is NO other way to do this. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome