{c2}try
NMFTP.Connect;
{d}if NMFTP.Connected then
begin
sDownFileDir:=sUpDownFilesDIR+'DownFile';
iDownTRYTIMES:=iDownTRYTIMES+1;
iDownTRYTIMESTmp:=iDownTRYTIMES; {e}while (iDownTRYTIMESTmp=iDownTRYTIMES) or (bDownFailture and (iDownTRYTIMES>0)) do
begin
bDownFailture:=false;
DownfileDestList.Clear;
DownfileSourseList.Clear; NMFTP.disConnect;
NMFTP.Connect;
if sDownHOSTDIR<>'' then
NMFTP.ChangeDir(sDownHOSTDIR);
Timer2.Enabled:=true;
try
NMFTP.ParseList:=true;
NMFTP.list;
Except
FStreamDown.free;
CloseFile(OutputFileDown);
DownfileSourseList.Free;
DownfileDestList.Free;
Timer2.Enabled:=false;
exit;
end;
Timer2.Enabled:=false;
iCount:=NMFTP.FTPDirectoryList.name.Count;
if cbTS.checked then
writeln(OutputFileDown,datetimetostr(now)+'将共下载'+inttostr(iCount)+'个文件');
if (iCount=0) then
begin
NMFTP.Disconnect;
exit;
end;
bDownProcess:=true;
for i:=0 to iCount-1 do //down file
begin
begin
sDownDest:=NMFTP.FTPDirectoryList.name.Strings[i];
sDownSouce:=sDownFileDir+'\'+sDownDest;
NMFTP.Download(sDownDest,sDownSouce);
if cbTS.checked then
writeln(OutputFileDown,datetimetostr(now)+'从'+sDownDest+' 下载到:'+sDownSouce);
end;
end; iCount:=DownfileDestList.Count;
if iCount>0 then
begin
for i:=0 to iCount-1 do //delete have down file
NMFTP.Delete(DownfileDestList.Strings[i]); NMFTP.Disconnect;
NMFTP.Connect; if sDownHOSTBAKDIR<>'' then //backup down file
begin
NMFTP.ChangeDir(sDownHOSTBAKDIR);
bDownProcess:=false;
for i:=0 to iCount-1 do
NMFTP.Upload(DownfileSourseList.Strings[i],DownfileDestList.Strings[i]);
end;
end; iDownTRYTIMES:=iDownTRYTIMES-1;
{e}end;
NMFTP.Disconnect;
{d}end;
except
FStreamDown.free;
writeln(OutputFileDown,datetimetostr(now)+' '+'连接不上FTP-'+sDownHost+','+'请检查网络是否连通,用户名密码是否正确!');
if bshowmessage then
showmessage('连接不上FTP-'+sDownHost+','+#13#10+'请检查网络是否连通,用户名密码是否正确!');
{c1}end;
NMFTP.Connect;
{d}if NMFTP.Connected then
begin
sDownFileDir:=sUpDownFilesDIR+'DownFile';
iDownTRYTIMES:=iDownTRYTIMES+1;
iDownTRYTIMESTmp:=iDownTRYTIMES; {e}while (iDownTRYTIMESTmp=iDownTRYTIMES) or (bDownFailture and (iDownTRYTIMES>0)) do
begin
bDownFailture:=false;
DownfileDestList.Clear;
DownfileSourseList.Clear; NMFTP.disConnect;
NMFTP.Connect;
if sDownHOSTDIR<>'' then
NMFTP.ChangeDir(sDownHOSTDIR);
Timer2.Enabled:=true;
try
NMFTP.ParseList:=true;
NMFTP.list;
Except
FStreamDown.free;
CloseFile(OutputFileDown);
DownfileSourseList.Free;
DownfileDestList.Free;
Timer2.Enabled:=false;
exit;
end;
Timer2.Enabled:=false;
iCount:=NMFTP.FTPDirectoryList.name.Count;
if cbTS.checked then
writeln(OutputFileDown,datetimetostr(now)+'将共下载'+inttostr(iCount)+'个文件');
if (iCount=0) then
begin
NMFTP.Disconnect;
exit;
end;
bDownProcess:=true;
for i:=0 to iCount-1 do //down file
begin
begin
sDownDest:=NMFTP.FTPDirectoryList.name.Strings[i];
sDownSouce:=sDownFileDir+'\'+sDownDest;
NMFTP.Download(sDownDest,sDownSouce);
if cbTS.checked then
writeln(OutputFileDown,datetimetostr(now)+'从'+sDownDest+' 下载到:'+sDownSouce);
end;
end; iCount:=DownfileDestList.Count;
if iCount>0 then
begin
for i:=0 to iCount-1 do //delete have down file
NMFTP.Delete(DownfileDestList.Strings[i]); NMFTP.Disconnect;
NMFTP.Connect; if sDownHOSTBAKDIR<>'' then //backup down file
begin
NMFTP.ChangeDir(sDownHOSTBAKDIR);
bDownProcess:=false;
for i:=0 to iCount-1 do
NMFTP.Upload(DownfileSourseList.Strings[i],DownfileDestList.Strings[i]);
end;
end; iDownTRYTIMES:=iDownTRYTIMES-1;
{e}end;
NMFTP.Disconnect;
{d}end;
except
FStreamDown.free;
writeln(OutputFileDown,datetimetostr(now)+' '+'连接不上FTP-'+sDownHost+','+'请检查网络是否连通,用户名密码是否正确!');
if bshowmessage then
showmessage('连接不上FTP-'+sDownHost+','+#13#10+'请检查网络是否连通,用户名密码是否正确!');
{c1}end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货