我在做FTP的时候用到了TIdFTP组件的List过程
具体过程如下:
procedure TFMain.RemoteChangeDirExecute(Sender: TObject);
Var
  LS: TStringList;
  FileCount : Integer;
  newItem : TListItem;
  FolderCount : Integer;
begin
    LS := TStringList.Create;
   try
    FTPClient.ChangeDir(ComboHistory.Text);
    RemoteFileList.Items.Clear;
    FTPClient.List(LS);
    FolderCount := 0;
    for FileCount:=0 to LS.Count - 1 do
    begin
      if FTPClient.DirectoryListing.Items[FileCount].ItemType = ditDirectory then
      begin
        newItem := RemoteFileList.Items.Insert(FolderCount);
        newItem.ImageIndex := 0;
        newItem.subItems.Add('文件夹');
      end
      else begin
        newItem := RemoteFileList.Items.Add;
        newItem.ImageIndex := 1;
        newItem.subItems.Add('');
      end ;
      newItem.Caption := FTPClient.DirectoryListing.Items[FileCount].FileName;
      newItem.subItems.Add(IntToStr(FTPClient.DirectoryListing.Items[FileCount].Size));
      newItem.subItems.Add(DateToStr(FTPClient.DirectoryListing.Items[FileCount].ModifiedDate));
    end;
  finally
    LS.Free;
  end;end;
我觉得没什么问题了,可是运行的时候老是说:list index out of bounds苦想了四五天,也不知道该怎么么改