我这里有一个,我用过很不错,要的话发给你,给我email。

解决方案 »

  1.   

    一点都不难:
    //==============================================================================
    //下载最新的客户端**************************************************************
    //==============================================================================
    procedure ClientDownload;
    var NMFTP: TNMFTP;
    begin
      NMFTP := TNMFTP.Create(nil);
      NMFTP.Vendor := 2411;
      NMFTP.Host := Remote.Computer;
      NMFTP.Port := 21;
      NMFTP.Timeout := 5000;
      NMFTP.UserID := 'anonymous';
      NMFTP.Password := '[email protected]';
      try
        NMFTP.Connect;
        NMFTP.Download(Native.AppName, Native.AppPath + Native.AppName + '~');
      finally
        NMFTP.Disconnect;
        NMFTP.Free;
      end;
    end;
      

  2.   

    我遇到的问题是list很多时候都不能得到东西,很慢,还不能中断chanel,idny的idftp虽然list好用,但是put不好用,get也不好断点续传,而且list出来的东西还要自己分析文件名,时间,大小,属性,遇到时间表示方法不一样的主机,遇到带空格的文件名就废了.怎么分析?
      

  3.   

    procedure AddList(ListView:Tlistview);
    var
    newitem:Tlistitem;
    i:integer;
    fd:tftpdirectorylist;
    begin
      listview.Items.BeginUpdate;
      fd:=tftpdirectorylist.Create;
      
      for i:=0 to flist.Count-1 do
      begin
        fd.ParseLine(flist.Strings[i]);
      end;
      for i:=0 to fd.name.Count-1 do
      begin
        newitem:=tlistitem.Create(listview.Items);
        newitem:=listview.Items.Add;
        newitem.caption:=fd.name.Strings[i];
        newitem.SubItems.Add(fd.Size.Strings[i]);
        newitem.SubItems.Add(fd.Attribute.Strings[i]);
        newitem.SubItems.Add(fd.ModifDate.Strings[i]);
      end;
      listview.Items.EndUpdate;
      fd.Free;end;
    //其中flist是一个全局变量,已经被idftp.list(flist)处理过了;
    //为什么fd.name.count竟然是0??
    //我确信当前目录不是空目录.
      

  4.   

    Description
    The TFTPDirectoryList object is the base class for all of the other FTP Directory List parsing objects. If you encounter an FTP host that does not comply with any of the predefined list objects currently available, you can use this class to derive your own list parser.Each property of this object is a TStringList. The indexes of each property correspond with the same index in each of the other properties. So name[1] and Attribute[1] contain the name and attributes for the second (TStringLists are 0-based) item in the listing.
    //////////
    帮助里面明明说的可以使用呀!
      

  5.   

    给两个函数用来取得目录列表和所有文件列表。
    function GetFTPDirList(FileNameStrings: TStringList;LsStrings:TStrings): Integer;
    var
      i:Integer;
      intSize:Integer;    
      tempString :String;
      IsDirectory:Boolean;
    begin
      Result := 0;
      FileNameStrings.Clear;
      for i:=0 to LsStrings.Count -1 do
         begin
            if(i=0)then
              if(Pos('total',LsStrings.Strings[0])=1)then
               begin
                  continue;
               end;
            tempString := GetNameFromDirLineSingle(LsStrings[i],IsDirectory,intSize);
            if IsDirectory and (tempString <>'.')and(tempString <> '..')then
               begin
                  FileNameStrings.Add(tempString);
               end;
         end;
    end;function GetFTPFileList(FileNameStrings,SizeStrings:TStringList;LsStrings:TStrings): Integer;
    var
      i:Integer;
      intSize:Integer;
      tempString :String;
      IsDirectory:Boolean;
    begin
      Result := 0;
      FileNameStrings.Clear;
      if SizeStrings <> nil then
         SizeStrings.Clear;
      for i:=0 to LsStrings.Count -1 do
         begin
            if(i=0)then
             if (Pos('total',LsStrings.Strings[0])=1)then
               begin
                  continue;
               end;
            tempString := GetNameFromDirLineSingle(LsStrings[i],IsDirectory,intSize);
            if not IsDirectory then
               begin
                  FileNameStrings.Add(tempString);
                  if SizeStrings <> nil then
                     begin
                        SizeStrings.Add(IntToStr(intSize));
                     end;
               end;
         end;
    end;function GetNameFromDirLineSingle(Line: String;var IsDirectory:Boolean;var intSize:Integer): String;
    Var
      i: Integer;
      DosListing: Boolean;
      tempString :String;
    begin
      IsDirectory := Line[1] = 'd';
      DosListing := false;
      for i := 0 to 7 do
        begin
           if (i = 2) and not IsDirectory then
            begin
                IsDirectory := Copy(Line, 1, Pos(' ', Line) - 1) = '<DIR>';
                if not IsDirectory then
                    DosListing := Line[1] in ['0'..'9']
                else
                    DosListing := true;
            end;
           tempString := Copy(Line,1,Pos(' ',Line)-1);
           case i of
              0:
               begin
               end;
              1:
               begin
               end;
              2:
               begin
               end;
              3:
               begin
               end;
              4:
               begin
                 try
                     intSize := StrToInt(tempString);
                 except
                     intSize := 0;
                 end;
               end;
              5:
               begin
               end;
              6:
               begin
               end;
              7:
               begin
               end;
           else
           end;
           Delete(Line, 1, Pos(' ', Line));
           While Line[1] = ' ' do
             Delete(Line, 1, 1);
           if DosListing and (i = 2) then break;
        end;
      Result := Line;
    end;