Hola Lepuke.
No sé si te termino de entender, pero para almacenar en la variable de tipo
string el contenido del archivo de texto podes hacer:
Código Delphi
[-]
function GetStringFromTxt(const FileName: TFileName): string;
begin
with TStringList.Create do
try
LoadFromFile(FileName);
Result := Text;
finally
Free;
end;
end;
Y para almacenar en el archivo de texto el contenido de la variable de tipo
string:
Código Delphi
[-]
procedure SaveStringToTxt(const Str: string; const FileName: TFileName);
begin
with TStringList.Create do
try
Text := Str;
SaveToFile(FileName);
finally
Free;
end;
end;
Ejemplos de uso:
Código Delphi
[-]
...
var
s: string;
begin
SaveStringToTxt(s, 'C:\Carpeta\Cadena1.txt');
s := GetStringFromTxt('C:\Carpeta\Cadena2.txt');
...
Saludos
