Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   error con idFTP (https://www.clubdelphi.com/foros/showthread.php?t=59254)

Meiziu 19-08-2008 11:00:21

error con idFTP
 
si en el directorio raiz del FTP (/tmp) no hay ningun archivo con extension .DAT me devuelve una excepción "*.*: No such file or directory." , si hay alguna fichero con esa extension funciona perfectamente.

Devuelve algun parámetro la función idFTP.List para saber si está vacío o no el directorio?

Código Delphi [-]
function TIfSGFTP.ListaArchivos(extension: string = '*'): TStrings;
var
  x: Integer;
begin

  try

    miListaArchivos := TStringList.Create;
    TStringList(miListaArchivos).Sorted := True;
    if FIdFTP.Connected then
      FIdFTP.List(miListaArchivos, '*.*', False);

    if extension <> '*' then
    begin
      extension := '.' + UpperCase(extension);
      x := 0;
      while x <= (miListaArchivos.Count -1) do
        if UpperCase(ExtractFileExt(miListaArchivos[x])) = extension then
          Inc(x)
        else
          miListaArchivos.Delete(x);
    end;
    Result := miListaArchivos;

  except
    on E:Exception do
    begin
      EscribeLog('ERROR', 'Error obteniendo la lista de archivos en directorio FTP');
      EscribeLog('ERROR', E.Message);
      raise;
    end;
  end;

end;

listaArchivos ('DAT');

un saludo y gracias.

Neeruu 19-08-2008 17:44:05

error con idFTP
 
Código Delphi [-]
procedure ListarDirectorio(Sender :TObject);
var MysList:TStringList;
iLines, iPesoArchivo:Integer;
sDir:String;
begin
  //Carga en una ListBox las Capetas y en Otra Los Archivos
  MysList := TStringList.Create;
  With FrmMain do
    begin
      ListBoxDir.Items.Clear;
      ListBoxFile.Items.Clear;
      ftp.List(MysList,'',False
      EditCurrentDir.Text := ftp.RetrieveCurrentDir;
      For iLines := 0 to MysList.Count -1 do
        begin
          sDir         := MysList[iLines];
          iPesoArchivo := FTP.Size(sDir);
          if iPesoArchivo = -1 then // Carpetas
              ListBoxDir.Items.Add(sDir)
          else ListBoxFile.Items.Add(sDir); //Archivos
        end;
    end;
  //Otra Forma de Mostrar el Directorio del Ftp
  {MysList := TStringList.Create;
  With FrmMain do
    begin
      ftp.List(MysList,'',False);
      ListBoxDir.Lines.Clear;
      ListBoxDir.Lines.AddStrings(MysList);
    end;
  MysList.Free;}
end;

Hola aca pongo la forma que utilizo yo para listar carpetas y archivos!!!
Muestr las carpetas por un lado y los archivos por otro!!!


Fijate que puede servirte!!!

Saluda Atte Neeruu!!!:)

Cita:

Fijate que tu recuoperas los archivos de la siguiente manera: FTP.List(MysList,'*.*',False);

y yo lo hago haci : FTP.List(MysList,'',False);


La franja horaria es GMT +2. Ahora son las 13:03:21.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi