I need a StringHelper which saves a string to a file:
var
s: string;
begin
s := 'Some text';
s.SaveTo('C:\MyText.txt');
end;
Unfortunately, this is not possible. Is it possible to add such a StringHelper?
I need a StringHelper which saves a string to a file:
var
s: string;
begin
s := 'Some text';
s.SaveTo('C:\MyText.txt');
end;
Unfortunately, this is not possible. Is it possible to add such a StringHelper?
It is possible to add such a helper. For instance:
The downside to doing so is that this will replace the string helper that is provided by the RTL. If you don't use it, that won't matter. If you do use it, then that's a problem that cannot readily be overcome.
You could look at this a different way. Instead of trying to use a helper on the
string
type, you could useTFile.WriteAllText
instead.Obviously you can use a different encoding if you prefer.