【问题标题】:Downloading directory from FTP server with Delphi XE使用 Delphi XE 从 FTP 服务器下载目录
【发布时间】:2020-03-12 14:20:52
【问题描述】:

我使用了this codes,但有时我会收到'“xxx.xxx”不理解'的错误消息。而且它没有下载,而且我收到“无法建立数据连接:连接超时”消息。

我的 ConnectionTimeOut 设置是 240000。

我能做什么?你能帮我吗?我正在使用 Delphi XE。

祝你有美好的一天。

【问题讨论】:

  • 您引用的代码不包括实例化ftp 也不包括将其设置为连接。请在您的代码未连接时显示该代码。

标签: delphi ftp


【解决方案1】:

最好包含您自己的代码来解决您的问题。但是,要下载我的文件, 我在服务器上压缩文件或文件夹,然后在客户端收到以下代码:

var
  STListZip: TStringList;
  SZipDown: String;
  fFtp:TIdFTP;
begin
  fFtp := TIdFTP.Create(nil);

  fFtp.Passive := true;
  fFtp.Host := 'myserver.com';
  fFtp.Username := 'u1';
  fFtp.Password := '1';
  fFtp.port:='21';
  fFtp.ConnectTimeout := 20000;
  fFtp.TransferTimeout := 20000;
  try
    fFtp.Connect;
    fFtp.ChangeDir('');
  except
    on E: Exception do
    begin
      ShowMessage('ERROR ftp not connect');
      Exit;
    end;
  end;

  if fFtp.Connected then
  begin
    STListZip := TStringList.Create;
    fFtp.List(STListZip, 'abc.zip', false);
    if STListZip.Count < 1 then
    begin
      ShowMessage('ERROR file not exist');
      Exit;
    end;
    STListZip.Sort;
    SZipDown := STListZip[STListZip.Count - 1];
    try
        fftp.BeginWork(wmRead);
        fftp.Get(SZipDown, 'd:\', true, fftp.ResumeSupported);
        fftp.Disconnect();
        fftp.EndWork(wmRead);
    except
        on E: Exception do
        begin
          ShowMessage('ERROR File not download');
          Exit;
        end;
    end;
  end;
end;

注意:你可以用*.zip代替abc.zip来获取所有的zip文件名。

【讨论】:

    猜你喜欢
    • 2014-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多