我在抄写一个书上FTP 客户端的时候。有这样的一条代码
    
   if  ftp1.DirectoryListing.Items[filecount].ItemType = 'ditDirectory'
      then 
          .........
            
报错说 [Error] Unit_main.pas(89): Incompatible types: 'String' and 'TIdDirItemType'
   怎么办?      

解决方案 »

  1.   

    procedure   TFMain.RemoteChangeDirExecute(sender:Tobject);
    var
        ls :Tstringlist;
        filecount : integer;
        newitem : Tlistitem;
        foldercount : integer;begin
        try
           ls := Tstringlist.Create;
           ftp1.ChangeDir(comboxremote.Text);
           listvremote.Items.Clear;
           ftp1.List(ls);
         foldercount := 0 ;
          for filecount := 0 to ls.Count -1 do
          begin
              if   (ftp1.DirectoryListing.Items[filecount].ItemType = 'ditDirectory')
                then
                    begin
                       newitem := listvremote.Items.Insert(foldercount);
                       newitem.ImageIndex := 0;
                       newitem.SubItems.Add('文件夹');
                    end
                 else
                    begin
                     newitem := listvremote.Items.Add;
                     newitem.SubItems.Add('');
                    end;            newitem.Caption := ftp1.DirectoryListing.Items[filecount].FileName;            newitem.SubItems.Add(inttostr(ftp1.DirectoryListing.Items[filecount].Size));            newitem.SubItems.Add(datetostr(ftp1.DirectoryListing.Items[filecount].ModifiedDate));
          end;
          finally
            ls.Free;
          end;end;
      

  2.   

    你用的是不是delphi自带的FTP工具啊?这个工具有问题的,我以前开发过,能用但问题很多,总之不稳定