Ver Mensaje Individual
  #7  
Antiguo 25-06-2025
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.669
Reputación: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
Está mal esa línea que muestra el error:
Código Delphi [-]
FTP.List(FileList, '*.pdf',True);
Ahí no puedes indicar que quieres listar los pdf, ahí va el directorio.


Código Delphi [-]
uses
  IdFTP, IdComponent, IdGlobal, SysUtils, Classes;

function ExistePDFEnFTP(Host, Usuario, Clave, Directorio, NombrePDF: string): Boolean;
var
  FTP: TIdFTP;
  ListaArchivos: TStringList;
  i: Integer;
begin
  Result := False;
  FTP := TIdFTP.Create(nil);
  ListaArchivos := TStringList.Create;
  try
    FTP.Host := Host;
    FTP.Username := Usuario;
    FTP.Password := Clave;
    FTP.Connect;

    if Directorio <> '' then
      FTP.ChangeDir(Directorio);

    // Obtener listado de archivos
    FTP.List(ListaArchivos, '', False);

    for i := 0 to ListaArchivos.Count - 1 do
    begin
      // Normaliza el nombre a minúsculas para evitar problemas con mayúsculas
      if SameText(ExtractFileExt(ListaArchivos[i]), '.pdf') then
      begin
        if (NombrePDF = '') or SameText(ListaArchivos[i], NombrePDF) then
        begin
          Result := True;
          Break;
        end;
      end;
    end;

    FTP.Disconnect;
  finally
    ListaArchivos.Free;
    FTP.Free;
  end;
end;
Responder Con Cita