Board index » delphi » send File with FTP and list files in a SLV

send File with FTP and list files in a SLV

--

Bas Gooijen

Quote
"Alex" <a...@d-projects.de> wrote in message

news:3e216546$1@newsgroups.borland.com...

Quote
> Hi,
> I'm writing a FTP Server and a Client.

> The second Problem is that I want to list the Stringlist, which I get when
I
> use the list command of the FTPClient, in a ShellListView or, if this is
not
> possible, in another component.

You'll need to copy them manually, like this:

var
  list: TIdFTPListItems;
  ListItem: TListItem;
  a: integer;
begin
  listview.items.BeginUpdate;
  try
    ftp.list(nil);
    listview.Items.Clear;

    list := ftp.DirectoryListing;
    for a := 0 to list.Count - 1 do begin
      if not ((list.Items[a].FileName = '.') or (list.Items[a].FileName =
'..')) then begin
        ListItem := listview.Items.Add;
        ListItem.Caption := list.Items[a].FileName;
        ListItem.SubItems.Add(inttostr(list.Items[a].Size));
        ListItem.SubItems.Add(DateTimeToStr(list.Items[a].ModifiedDate));
      end;
    end;
  finally
    listview.items.EndUpdate;
  end;
end;

Bas

 

Re:send File with FTP and list files in a SLV


Quote
"Bas Gooijen" <bas_gooi...@yahoo.com> wrote in message

news:3e216800$1@newsgroups.borland.com...
Quote

> You'll need to copy them manually, like this:

> var
>   list: TIdFTPListItems;
>   ListItem: TListItem;
>   a: integer;
> begin
>   listview.items.BeginUpdate;
>   try
>     ftp.list(nil);
>     listview.Items.Clear;

>     list := ftp.DirectoryListing;
>     for a := 0 to list.Count - 1 do begin
>       if not ((list.Items[a].FileName = '.') or (list.Items[a].FileName =
> '..')) then begin
>         ListItem := listview.Items.Add;
>         ListItem.Caption := list.Items[a].FileName;
>         ListItem.SubItems.Add(inttostr(list.Items[a].Size));
>         ListItem.SubItems.Add(DateTimeToStr(list.Items[a].ModifiedDate));
>       end;
>     end;
>   finally
>     listview.items.EndUpdate;
>   end;
> end;

> Bas

Hi,
unfortunately I get the Error "Unkown FTP listing format" at
Quote
>>>list := ftp.DirectoryListing; <<<

I think

Re:send File with FTP and list files in a SLV


Yeah
thanx, it works.

Just another Question:
(How) can I bind it to a process bar?

Re:send File with FTP and list files in a SLV


mine looks like this:

procedure TFTPServer.IdFTPServer1ListDirectory( ASender: TIdFTPServerThread;
const APath: string; ADirectoryListing: TIdFTPListItems ) ;

  procedure AddlistItem( aDirectoryListing: TIdFTPListItems; Filename:
string; ItemType: TIdDirItemType; size: int64; date: tdatetime ) ;
  var
    listitem: TIdFTPListItem;
  begin
    listitem := aDirectoryListing.Add;
    listitem.ItemType := ItemType;
    listitem.FileName := Filename;
    listitem.OwnerName := 'anonymous';
    listitem.GroupName := 'all';
    listitem.OwnerPermissions := '---';
    listitem.GroupPermissions := '---';
    listitem.UserPermissions := '---';
    listitem.Size := size;
    listitem.ModifiedDate := date;
  end;

var
  f: tsearchrec;
  a: integer;
begin
  ADirectoryListing.DirectoryName := apath;

  a := FindFirst( TransLatePath( apath, ASender.HomeDir ) + '*.*',
faAnyFile, f ) ;
  while ( a = 0 ) do
  begin
    if ( f.Attr and faDirectory > 0 ) then
      AddlistItem( ADirectoryListing, f.Name, ditDirectory, f.size,
FileDateToDateTime( f.Time ) )
    else
      AddlistItem( ADirectoryListing, f.Name, ditFile, f.size,
FileDateToDateTime( f.Time ) ) ;
    a := FindNext( f ) ;
  end;

  FindClose( f ) ;
end;

Bas

Other Threads