Tia86
asked on
search and overwrite binary files data
how i can replace a string into binary files BUT the 2 two strings haven't same length?
eg. old string = "Hi"
new string = "Hello"
example??
bye , tia86
125 points for the correct answer
eg. old string = "Hi"
new string = "Hello"
example??
bye , tia86
125 points for the correct answer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
procedure TForm1.Button1Click(Sender
var
f: file;
l: Longint;
FileName, oldstring, newstring, s: string;
begin
oldstring := 'old_string';
newstring := 'new_string';
FileName := 'file.xyz';
s := oldstring;
AssignFile(f, FileName);
Reset(f, 1);
for l := 0 to FileSize(f) - Length(oldstring) - 1 do
begin
Application.ProcessMessage
Seek(f, l);
BlockRead(f, oldstring[1], Length(oldstring));
if oldstring = s then
begin
Seek(f, l);
BlockWrite(f, newstring[1], Length(newstring));
ShowMessage('String successfully replaced!');
end;
Application.ProcessMessage
end;
CloseFile(f);
end;
but don't work if the 2 strings haven't same lenght...
help me!