原来我的项目是在D7下开发的,现在升级到D2007下,怎么是用FTP显示目录时,出错错误。真奇怪。注编译时不出错误。我已经将错误处进行了标识。procedure TFrmFtpTrans.DisplayRemoteFileList();
Var
  LS: TStringList;
  ICount : Integer;
  newItem : TListItem;
begin
  try
    LS := TStringList.Create;
    ListViewRemoteFile.Items.Clear;  //清空远程文件列表
    ListViewRemoteFile.Clear;
    FTPClient.List(LS);    //得到文件和目录列表
    //ListViewRemoteFile.Items.Assign(LS);
    //处理LS的每个项目
    for ICount:=0 to LS.Count-1 do
    begin
      //是目录吗?
     With FTPClient.DirectoryListing.Items[ICount] Do begin   //这里出错。[:(!]
      if ItemType = ditDirectory then
      begin
        //添加目录项目
        newItem := ListViewRemoteFile.Items.Insert(0);
        newItem.ImageIndex := 0;   //图标序号
        newItem.subItems.Add('文件夹');
      end
      else
      begin
        //添加文件项目
        newItem := ListViewRemoteFile.Items.Add;
        newItem.ImageIndex := 1;     //图标序号
        newItem.subItems.Add('');
      end ;
      newItem.Caption := FTPClient.DirectoryListing.Items[ICount].FileName;   //文件名
      newItem.subItems.Add(IntToStr(FTPClient.DirectoryListing.Items[ICount].Size));  //文件大小
      newItem.subItems.Add(DateTimeToStr(FTPClient.DirectoryListing.Items[ICount].ModifiedDate)); //时间
     end;
    end;
  finally
    LS.Free;   //释放TStringList
  end;
end;  

解决方案 »

  1.   

    Indy版本不一致?
    Debug到Indy源码上看吧
      

  2.   

    delphi2007 默认安装indy10,而delphi7默认安装indy9,indy10并不兼容indy9,有好多东西已经改了,或者去掉了
      

  3.   

    Indy10需要在你的单元里面引用IdAllFTPListParsers单元才能正确解析DirectoryListing对象,否则它一直都是nil.自己解决了,弄了一天了,真晕。