Re: Resume function not correctly download my file (General questions)
Have re-import type library and still have the same.
Basically there're only 2 main function in my program, those are Connect2FtpServer and GetFileViaFtp. Here're the detail:
function TForm1.Connect2FtpServer: boolean;
var
isConnected: boolean;
i: integer;
begin
try
try
i:= 0;
isConnected:= false;
while (not isConnected)and(i<=10) do
begin
try
MywodFtp.Hostname:= Edit3.Text;
MywodFtp.Port:= strtoint(Edit6.Text);
MywodFtp.Protocol:= ComboBox1.ItemIndex;{use 4 for implicit}
MywodFtp.Blocking:= true;
MywodFtp.Login:= Edit4.Text;
MywodFtp.Password:= Edit5.Text;
MywodFtp.Disconnect1;
if i<>0 then
begin
Sleep(1000);
memo1.Lines.Add('RESUME CONNECT #'+inttostr(i));
end;
MywodFtp.Connect1;
isConnected:= true;
except
isConnected:= false;
end;
i:= i+1;
end;
finally
result:= isConnected;
end;
except
result:= false;
end;
end;
function TForm1.GetFileViaFtp(rfname, fname: string; var err: string;
isResume: boolean): boolean;
var
i: integer;
isSuccess: boolean;
tmpFName: string;
isDownloaded: boolean;
begin
try
if Length(rfname)>0 then
if rfname[1]<>'/' then
rfname:= '/'+ rfname;
isResume:= false;
if rfname[Length(rfname)]<>'/' then
begin
Result:= true;
i:=0;
isSuccess:= false;
while (not isSuccess)and(i<10) do
begin
try
if i=0 then
begin
MywodFtp.Resume:= false;
MywodFtp.GetFile(fname,rfname);
end else
begin
Sleep(1000);
isResume:= isResume;
MywodFtp.Resume:= true;
Memo1.Lines.Add('RESUME #'+inttostr(i+1));
MywodFtp.GetFile(fname,rfname);
end;
isSuccess:= true;
except
on e: Exception do
begin
isSuccess:= false;
err:= e.Message;
if e.Message='Cannot execute, not yet connected' then
Connect2FtpServer;
if (e.Message='Requested action not taken. File unavailable (e.g., file not found, no access)') then
isSuccess:= true
else
isSuccess:= false;
end;
end;
i:= i+1;
end;
result:= isSuccess;
end else
begin
Result:= true;
end;
except
on E: Exception do
begin
result:= false;
err:= e.Message;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
err: string;
begin
if Connect2FtpServer then
begin {use true to resume mode}
if GetFileViaFtp(Edit1.Text,Edit2.Text,err,CheckBox1.Checked) then
begin
MessageDlg('Download process finished',mtConfirmation,[mbOK],0);
end else
begin
MessageDlg('Download process finished',mtError,[mbOK],0);
end;
end else
begin
MessageDlg('Can not connect to FTPServer',mtError,[mbOK],0);
end;
end;
----- finished ---
Is there something missed with that code?
Complete thread:
- Resume function not correctly download my file - rossi, 2006-07-24, 07:19
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-24, 08:32
- Re: Resume function not correctly download my file - rossi, 2006-07-24, 09:25
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-24, 10:25
- Re: Resume function not correctly download my file - rossi, 2006-07-24, 11:04
- Re: Resume function not correctly download my file - rossi, 2006-07-24, 11:11
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-24, 11:19
- Re: Resume function not correctly download my file - rossi, 2006-07-24, 12:35
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-24, 13:14
- Re: Resume function not correctly download my file - rossi, 2006-07-25, 07:35
- Re: Resume function not correctly download my file - wodDamir, 2006-07-25, 09:21
- Re: Resume function not correctly download my file - rossi, 2006-07-25, 10:20
- Re: Resume function not correctly download my file - wodDamir, 2006-07-25, 13:06
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-25, 17:07
- Re: Resume function not correctly download my file - rossi, 2006-07-26, 05:47
- Re: Resume function not correctly download my file - rossi, 2006-07-26, 05:59
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-28, 10:42
- Re: Resume function not correctly download my file - rossi, 2006-07-26, 05:59
- Re: Resume function not correctly download my file - rossi, 2006-07-26, 05:47
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-25, 17:07
- Re: Resume function not correctly download my file - wodDamir, 2006-07-25, 13:06
- Re: Resume function not correctly download my file - rossi, 2006-07-25, 10:20
- Re: Resume function not correctly download my file - wodDamir, 2006-07-25, 09:21
- Re: Resume function not correctly download my file - rossi, 2006-07-25, 07:35
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-24, 13:14
- Re: Resume function not correctly download my file - rossi, 2006-07-24, 12:35
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-24, 11:19
- Re: Resume function not correctly download my file - rossi, 2006-07-24, 11:11
- Re: Resume function not correctly download my file - rossi, 2006-07-24, 11:04
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-24, 10:25
- Re: Resume function not correctly download my file - rossi, 2006-07-24, 09:25
- Re: Resume function not correctly download my file - wodDrazen, 2006-07-24, 08:32