Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. type
  2. TByteArray = array of byte;
  3.  
  4. function FileReadAllBytes(fileName: string): TByteArray;
  5. const
  6. readBufSize = 1023;
  7. var
  8. res: TByteArray;
  9. myFile: File of byte;
  10. readBuf: array [0..readBufSize] of byte;
  11. i, j: integer;
  12. readInFact: integer;
  13. begin
  14. AssignFile(myFile, fileName);
  15. Reset(myFile);
  16. SetLength(res, FileSize(myFile));
  17. i := 0;
  18. repeat
  19. blockread(myFile, readBuf, readBufSize+1, readInFact);
  20. for j := 0 to readInFact - 1 do
  21. begin
  22. res[i] := readBuf[j];
  23. i := i + 1;
  24. end;
  25. until i >= FileSize(myFile);
  26. Result := res;
  27. end;
  28.  
  29. var
  30. test3: TByteArray;
  31. ....
  32. test3 := FileReadAllBytes('bigfile.txt');
  33. IdTCPClient1.WriteBuffer(Pointer(test3)^, Length(test3));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement