Hi!
This is my first post on this forum, despite the fact that I have been reading it for many years.
I have a question that I cannot figure out on my own, so I decided to ask here.
I have several hundred of binary files up to 20 MB in size (task for the Windows platform).
The first 100 bytes of some files contain ANSI-string up to 10 characters long. I need to go through all the files, determine if the file contains this line, and if it does, then replace it with another line (with the same length), while not changing any other bytes from the file, and overwrite it back to the disk.
After several hours of reading forums and programming, I have not found a simple and fast solution.
First, I loaded the full file in memory (may be not the fastest way, I didn't figure out how to work only with first, let say, 100 bytes of file).
I tried opening binaries in a TStringList, but after saving back to disk, LF bytes were changed to a CR LF (determined as line end delimiter). Tried TMemoryStream, but couldn't find an efficient way to find and replace a string. I haven’t figured it out to the end with TStringStream.
Please advise what is the easiest and fastest way to solve this problem.
Thank you in advance.