FTP多线程切割传输
2008-09-23 19:27:14 来源:WEB开发网2.FTP线程类
unitUnitFtpPhotoData;
interface
uses
Windows,SysUtils,Variants,Classes,StdCtrls,Controls,IdBaseComponent,
IdComponent,IdTCPConnection,IdTCPClient,IdFTP,
IdThreadComponent,IdAntiFreezeBase,IdAntiFreeze,Dialogs;
const
ZZ_FTP_IP='127.0.0.1';
ZZ_FTP_PORT=21;
type
TFtpPhotoData=class(TIdFtp)
private
{Privatedeclarations}
public
procedureCreateFtpThread(idFTP:TIdFTP;aUserName,aPassword,
aOrgFileName,aDestFileName:string);
procedureDoWork(AWorkMode:TWorkMode;constACount:Integer);override;
procedureEndWork(AWorkMode:TWorkMode);override;
published
{Publisheddeclarations}
{公布子组件的事件}
{Publicdeclarations}
end;
type
TFtpThread=class(TIdThreadComponent)
private
public
end;
implementation
{TFtpPhotoData}
procedureTFtpPhotoData.CreateFtpThread(idFTP:TIdFTP;aUserName,aPassword,
aOrgFileName,aDestFileName:string);
begin
idFtp.Host:=ZZ_FTP_IP;
idFtp.Port:=ZZ_FTP_PORT;
idFtp.Username:=aUserName;
idFtp.Password:=aPassword;
try
idFtp.Connect;
ifnotidFtp.Connectedthenbegin
//MsgBox('');
endelsebegin
idFtp.Put(aOrgFileName,aDestFileName,false);
//idFtp.
end;
except
idFtp.Quit;
end;
end;
procedureTFtpPhotoData.DoWork(AWorkMode:TWorkMode;constACount:Integer);
begin
ifACount=100thenbegin
showMessage('finishThread');
end;
end;
procedureTFtpPhotoData.EndWork(AWorkMode:TWorkMode);
begin
showMessage('finishThread');
//
end;
end.
3.调用程序
//TIdThreadComponent;TIdAntiFreeze;不常用的控件,线程和冻结
procedureTFrm_Ftp.IdThreadComponent_FtpRun(Sender:TIdCustomThreadComponent);
var
f:TIdFTP;
i:integer;
begin
f:=TIdFTP.Create(Self);
try
f.Username:='ftp';
f.Password:='ftp';
f.Host:='127.0.0.1';
f.Port:=21;
ifFThreadNumber>3thenbegin
self.IdThreadComponent_Ftp.Terminate;
self.IdThreadComponent_Ftp.Active:=False;
exit;
end;
try
f.Connect;
f.Put(FFileNameList[FThreadNumber],ExtractFileName(FFileNameList[FThreadNumber]),False);
sleep(10000);
f.Quit;
self.IdThreadComponent_Ftp.Terminate;
except
end;
finally
f.Free;
end;
inc(FThreadNumber);
end;
放在BLOG上,以后有机会再用,免得忘了。
- ››线程状态图
- ››FTP基础知识及模式精解
- ››FTP服务器如何实现安全性(上)
- ››FTP服务器如何实现安全性(下)
- ››FTP服务器完全手册
- ››FTP服务器的排错详解
- ››FTP与VSFTP
- ››FTP命令基本用法
- ››FTP服务器的攻防实战
- ››FTP多线程切割传输
- ››FTP服务器安全防范及数据备份
- ››FTP服务器架设的三方面安全因素
更多精彩
赞助商链接