TsgcWSPClient_FilesEvents › OnFileReceivedFragment

OnFileReceivedFragment Event

Fires every time a new fragment of an incoming file has been written to disk; ideal for progress indicators.

Syntax

property OnFileReceivedFragment: TsgcWSFileFragmentEvent;
// TsgcWSFileFragmentEvent = procedure(Connection: TsgcWSConnection; const aMessage: TsgcWSMessageFile; var Cancel: Boolean) of object

Default Value

Remarks

aMessage.FilePosition reports how many bytes have been stored so far and aMessage.FileSize the total expected size. Set Cancel to True to abort the download; the local stream is deleted and the sender is notified with an error.

Example

procedure TForm1.oProtocolFileReceivedFragment(Connection: TsgcWSConnection;
  const aMessage: TsgcWSMessageFile; var Cancel: Boolean);
begin
  ProgressBar1.Position := Round(aMessage.FilePosition / aMessage.FileSize * 100);
end;

Back to Events