Hi I have a problem with replacing a text in a textfile with Inno Setup (Delphi based).
My Code:
procedure
I hope this function does the job:
function FileReplaceString(const FileName, SearchString, ReplaceString: string):boolean;
var
MyFile : TStrings;
MyText : string;
begin
MyFile := TStringList.Create;
try
result := true;
try
MyFile.LoadFromFile(FileName);
MyText := MyFile.Text;
{ Only save if text has been changed. }
if StringChangeEx(MyText, SearchString, ReplaceString, True) > 0 then
begin;
MyFile.Text := MyText;
MyFile.SaveToFile(FileName);
end;
except
result := false;
end;
finally
MyFile.Free;
end;
end;
Kudos to TLama for feedback.