Einzelnen Beitrag anzeigen

mr_emre_d
(Gast)

n/a Beiträge
 
#3

Re: Datei in ein Bytearray einlesen

  Alt 20. Mai 2009, 21:28
Falls ne, dann *tritt,fg*:

Delphi-Quellcode:
type TByteArr = Array of Byte;

function ReadIn( const Filename: String ): TByteArr;
var
  f: File of Byte;
  Err: String;
begin
  if not FileExists(Filename) then
    Exit;
  {$i-}
  AssignFile( F, Filename );
  Reset( F );
  SetLength( Result, FileSize(F) );
  BlockRead( F, Result[0], Length(Result) );
  CloseFile( F );
  {i-}
  Err := SysErrorMessage( IOResult );
  if Err <> 0 then
    MessageBoxA( Handle, pChar( 'Error [' + IntToStr(IOResult) + ']'#13#10#13#10+Err ),
      'Error', MB_OK or MB_ICONERROR );
end;
  Mit Zitat antworten Zitat