TFtpClient.OnProgress

From Overbyte
Jump to: navigation, search

Main page -> ICS components reference -> TFtpClient -> OnProgress

Definition

procedure(Sender: TObject; Count  : LongInt; var Abort : Boolean) of object;


  • Sender : the client which fired the event
  • Count : the filesize count
  • Abort : Used to abort the transfer

Description

This event fires to indicate the fileprogress.

Example

Before you transfer the file retrieve the filesize and set it to the progressbar max property:

Progress.Max := getFileSize(FilenameEdit.Text);

In the event of progress do something like this:

procedure TMainForm.FtpClientProgress(Sender: TObject; Count: Integer; var Abort: Boolean);
begin
  Progress.Position := Count;
end;


This is the getFileSize-function

function getFileSize(pFileName: string): longint;
var
  sr: TSearchRec;
  FileAttrs: Integer;
begin
  FileAttrs := faReadOnly;
  FileAttrs := FileAttrs + faHidden;
  FileAttrs := FileAttrs + faSysFile;
  FileAttrs := FileAttrs + faVolumeID;
  FileAttrs := FileAttrs + faDirectory;
  FileAttrs := FileAttrs + faArchive;
  FileAttrs := FileAttrs + faAnyFile;
  if FindFirst(pFileName, FileAttrs, sr) = 0 then
  begin
    Result := sr.Size;
    FindClose(sr);
  end
  else
    Result := 0;
end;

Best practices

nothing yet