3
我是拉撒路新人的幾個月。我一直在嘗試創建一個小型FTP程序,它將在登錄後發送一個小文件。我完成了所有粘性的工作,我唯一關心的是FTP部分。我得到了一大堆錯誤的,我一直在努力安裝正確的軟件包有沒有簡單的方法在拉撒路代碼中使用FTP功能
我的FTP代碼如下所示
function TModel.Send(LocalFile : string; remoteFile : string; RemoteDir : string) : boolean;
//===========================================================================
// **********************************************************************
// * Send a file to the FTP server *
// **********************************************************************
//---------------------------------------------------------------------------
var
rc : boolean;
begin
// Create the FTP Client object and set the FTP parameters
FTPClient := TFTPSend.Create;
with FTPClient do begin
TargetPort := cFtpProtocol;
TargetHost := fHost; // these were properties set somewhere else
UserName := fUserID;
Password := fPassword;
//-----------------------------------------------------------------------
// bail out if the FTP connect fails
if not LogIn then exit;
//------------------------------------------------------------------------
// Set filename to FTP
DirectFileName := LocalFile;
DirectFile := True;
//------------------------------------------------------------------------
// change directory if requested
if RemoteDir <> '' then ChangeWorkingDir(RemoteDir);
//------------------------------------------------------------------------
// STOR file to FTP server.
rc := StoreFile(RemoteFile,false);
//------------------------------------------------------------------------
// close the connection
LogOut;
//------------------------------------------------------------------------
// free the FTP client object
free;
//------------------------------------------------------------------------
end;
Result := rc;
//===========================================================================
end;
感謝您的幫助。
謝謝你的碼 –