Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Apr : indy 10.1.5 IdFTP OnWork appears not to function?
| Subject: | indy 10.1.5 IdFTP OnWork appears not to function? |
| Posted by: | "Kerry Frater" (ker..@jcs.co.uk) |
| Date: | Wed, 2 Apr 2008 15:03:15 |
I am using ftp to upload a file. The code is working fine in that the files
are correctly being uploaded.
I wanted to have a progress bar to show the progress.
I looked at the source of the Indy Demo ftpclient program and decided to use
the progress bar that overlays the second panel of the statusbar.
Other than the name of the statusbar the OnWork, OnWorkBegin & OnWorkEnd
code is identical to the demo.
From the "blank" rectangle over the statusbar and text in Panels[2].Text I
know the OnWorkBegin and OnWorkEnd are both triggered. The OnWork appears
never to be triggered. The file being transferred (a 1.5Mb .wav file) takes
enough time that I would expect the event to occur.
The OnWorkEnd event occurs befor the end of the actual ftp.put code. The ftp
is in "passive" mode for the server.
Are there parameters to set in order to make the "OnWork" event to occur?
WorkBegin Code:
if AWorkMode = wmwrite then begin
pbProgress.Max := AWorkCountMax;
pbProgress.Position := 0;
pbProgress.Visible := true;
sb1.Panels[2].Text := 'Starting upload';
pbProgress.BringToFront;
refresh;
end;
WorkEnd Code:
if AWorkMode = wmwrite then begin
pbProgress.Visible := false;
sb1.Panels[2].Text := 'Upload completed here';
refresh;
end;
OnWork Code
if AWorkMode = wmwrite then begin
pbProgress.Position := AWorkCount;
Sb1.Panels[2].Text := IntToStr(AWorkCount);
refresh;
end;
The code that calls the "put"
Sb1.Panels[0].Text := '';
if not Ftp.Connected then begin
FTP.Connect;
Sb1.Panels[0].Text := 'Connected';
end;
if not Ftp.Connected then begin
Sb1.Panels[2].Text := 'Failed to connect to FTP Server';
exit;
end;
try
Ftp.MakeDir(MyDir);
except
end;
try
FTP.ChangeDir(MyDir);
except
SB1.Panels[2].Text := 'Instruction folder not available';
exit;
end;
try
FTP.Delete(TheFile);
except
end;
try
FTP.Put(EdLocalFile.Text,TheFile);
except
SB1.Panels[2].Text := 'Failed to upload '+EdLocalFile.Text;
end;
FTP.Disconnect;
Sb1.Panels[0].Text := 'Disconnected';
except
SB1.Panels[2].Text := 'Failed to Login to FTP Server';
end;
Any help given much appreciated.
Kerry