D2007下使用IdFTP

oushengfen 2007-11-12 03:15:00
原来我的项目是在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;
...全文
69 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
oushengfen 2007-11-12
  • 打赏
  • 举报
回复
Indy10需要在你的单元里面引用IdAllFTPListParsers单元才能正确解析DirectoryListing对象,否则它一直都是nil.

自己解决了,弄了一天了,真晕。
lee576 2007-11-12
  • 打赏
  • 举报
回复
delphi2007 默认安装indy10,而delphi7默认安装indy9,indy10并不兼容indy9,有好多东西已经改了,或者去掉了
ly_liuyang 2007-11-12
  • 打赏
  • 举报
回复
Indy版本不一致?
Debug到Indy源码上看吧

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧