如题:
  因为AFiles中获得的结果中包括了目录信息,如何区分目录与文件?

解决方案 »

  1.   

    Delphi 7 网络应用开发 飞思科技的书里有 区分目录与文件 的小算法
      

  2.   

    try 
       changdir();
    expect
      不是目录
    end;
    你用CHANGDIR如果有异常就是文件不是目录,如果不异常就是目录不是文件
      

  3.   

    //看看procedure TFormFTPClientMain.RemoteChangeDirExecute(Sender: TObject);
    Var
      LS: TStringList;
      FileCount : Integer;
      newItem : TListItem;
      FolderCount : Integer;
    begin
      try
        LS := TStringList.Create;
        FTPClient.ChangeDir(CbxHistory.Text);
        LViewRemoteFile.Items.Clear;
        FTPClient.List(LS);
        FolderCount := 0;
        for FileCount:=0 to LS.Count - 1 do
        begin
          if FTPClient.DirectoryListing.Items[FileCount].ItemType = ditDirectory then
          begin
            newItem := LViewRemoteFile.Items.Insert(FolderCount);
            newItem.ImageIndex := 0;
            newItem.subItems.Add('文件夹');
          end
          else
          begin
            newItem := LViewRemoteFile.Items.Add;
            newItem.ImageIndex := 1;
            newItem.subItems.Add('');
          end ;
          newItem.Caption := FTPClient.DirectoryListing.Items[FileCount].FileName;
          newItem.subItems.Add(IntToStr(FTPClient.DirectoryListing.Items[FileCount].Size));
          newItem.subItems.Add(DateToStr(FTPClient.DirectoryListing.Items[FileCount].ModifiedDate));
        end;
      finally
        LS.Free;
      end;
    end;