Einzelnen Beitrag anzeigen

Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.767 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: Save and Load dynamic array

  Alt 26. Jan 2012, 15:12
Hi,

it might work in this way (not tested).
SaveToFile works similar.

Delphi-Quellcode:
function TFileChecker.LoadFromFile(AFileName: string): boolean;
var
  iStream:TMemoryStream;
  buf: TFileSpec;
  i:Integer;
begin
  Result:=False;
  SetLength(FFileSpec, 0);

  iStream:= TMemoryStream.Create;
  Try
    iStream.LoadFromFile(AFileName);
    setLength(FFileSpec,iStream.size div SizeOf(TFileSpec));
    iStream.seek(0,soFromBeginning);
    i := 0;
    while iStream.Position < iStream.size do
       begin
          iStream.ReadBuffer(buf,sizeOf(TFileSpec));
          FFileSpec[i] := buf;
          inc(i);
       end;
    Result:=True;
  finally
    iStream.Free;
  end;

end;
Best regards
Klaus
Klaus

Geändert von Klaus01 (26. Jan 2012 um 15:15 Uhr)
  Mit Zitat antworten Zitat