13,825
社区成员
发帖
与我相关
我的任务
分享
try{
BeforFtp->Disconnect() ;
BeforFtp->Host = FtpServiceBeforHost;
BeforFtp->User = FtpServiceBeforUserName;
BeforFtp->Password = FtpServiceBeforPassWord;
BeforFtp->Port = FtpServiceBeforPort;
BeforFtp->Passive = BeforTransMod;
BeforFtp->TransferType = ftBinary;
BeforFtp->Connect() ;
if(FtpTransAfter == 0) TransAfterAddStr = "";
if(FtpTransAfter == 1) TransAfterAddStr = FormatDateTime("yyyymmddhhmmss",Now());
BeforFtp->Put(ADOQuery1->FieldByName("FilePath")->AsString+ADOQuery1->FieldByName("FileName")->AsString,BeforUpLoadDir + TransAfterAddStr + ADOQuery1->FieldByName("FileName")->AsString,true);
BeforFtp->Quit();
}
#ifdef debug
catch(Exception &exception)
{
IsTransOk = false;
Sysutils::ShowException(&exception, System::ExceptAddr());
}
#else
catch(...)
{
IsTransOk = false;
// MessageBox(NULL,"ftp传送文件出错","提示",0);
}
idftp2->Passive = true;
如果确信服务器没有问题得时候试试加一句这个,这个是使用被动模式,主要是防火墙造成得端口映射有问题。