zoukankan      html  css  js  c++  java
  • Idftp.DirectoryListing 里面的内容为什么会是空的呢?(转)

    最近在项目中要用到FTP上传,用的是delphi的IdFTP控件,用IdFtp.List(list),发现List里面有内容,可 是到IdFtp.DirectoryListing.Items[iCount].ItemType=ditDirectory却出现越界的错误,而 DirectoryListing .ListResult中却有内容,取出IdFtp.DirectoryListing.count确为0,惊讶了。琢磨了很久 ,这是查的一个关于DirectoryListing 的资料。

    最后发现由于D7以后的版本的intra控件升级,管理方式变了,需要在调用的单元是加一个文件IdAllFTPListParsers才搞定。现在贴出来,让大家少走点弯路。

    看了一下网上的代码都是List完了就直接用,DirectoryListing会自动解析ListResult

    放狗搜了半天,终于找到原因,原来是Indy10的一个设计上的变化,以下引用官网内容:

    TIdFTP.DirectoryListing is returning nothing for my FTP server. Why?

    We restructured the way FTP directory listing is done. The code is now a plug in system with various parsers in their own units which register themselves into a framework. To add support for a particular type of FTP server, you simply add the parser unit to one of your program unit’s uses clause.

    To add the Unix directory list parser, add IdFTPListParseUnix to your unit’s clause. To add support for Microsoft Windows NT IIS FTP server, add IdFTPListParseWindowsNT to your uses clause. You can also add many other parsers we include in the Indy packages. By convention, they are named IdFTPListParser followed by the server type. You do not need to add IdFTPListParseBase to your uses clause because IdFTP uses that unit. If you wish to use all of Indy’s FTP List parser classes, just add the IdAllFTPListParsers unit to your uses clause.

    We admit this new design is not as intuitive as the older one but this has many advantages for us such as:

    • The FTP list parsing code is now much easier to maintain than the same code in a non-modular design in one unit which would be at least 150KB total.

    • You now can add support for only the FTP servers you want your program support to support.

    • You can now write your own custom parser classes and plug those into the standard FTP parsing list framework.

    转自:http://hi.baidu.com/ningj123/item/1a1a1acfdb842063f6c95d2a

  • 相关阅读:
    WPF数据绑定之Ado.net的数据库连接绑定
    asp.net 网站js弹出提示后原页面css样式丢失
    Javascript中函数重载的实现
    JavaScript的继承
    WPF数据绑定之4种绑定模式
    Asp.net输出Excel文件并且下载该文件以及某些细节问题解决
    js 验证身份证 带X
    WPF的数据绑定之控件源绑定以及代码方式绑定
    WPF数据绑定之DataContext
    在无cookie模式中,会话话状态的ID将会自动保存在ASP.NET的查询字符串中
  • 原文地址:https://www.cnblogs.com/mumble/p/3384714.html
Copyright © 2011-2022 走看看