function LoadFile(const FileName: TFileName): string;
begin
with TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite) do
begin
try
SetLength(Result, Size);
Read(Pointer(Result)^, Size);
except
Result := ''; // Deallocates memory
Free;
raise;
end;
Free;
end;
end;
Jak zapisać stringa do pliku ?
procedure SaveFile(const FileName: TFileName; const content: string);
begin
with TFileStream.Create(FileName, fmCreate) do
try
Write(Pointer(content)^, Length(content));
finally
Free;
end;
end;
Brak komentarzy:
Prześlij komentarz