Calling GetFolderList() twice not possible?

Hello,

is it right, that I can't call GetFolderList() twice? With the follwoing code, I want get the files from a special folder and then the files from the subfolder. By calling the GetFolderList() a second time, I will get e.g. in Dropbox the error "Missing Folder Path", because "Folder as TDropBoxItem).Path" will be empty...

var
  ci, nci : TTMSFMXCloudItem;
  tmpItems, tmpFotos : TTMSFMXCloudItems;
  i: Integer;
  
  begin

    ci := nil;

    if Assigned(frameTVCloud.TreeView.Selected) then
    begin
      ci := TTMSFMXCloudItem(TTMSFMXCloudTreeViewItem(frameTVCloud.TreeView.Selected).DataObject);

      // when selected item is a file, upload to file parent folder
      if ci.ItemType = ciFile then
        ci := ci.ParentFolder;
    end;

    tmpItems := Storage.GetFolderList(ci);
    if tmpItems = NIL then
      exit;
    
    nci := NIL;
    for i := 0 to tmpItems.Count-1 do
    begin
      if tmpItems.Items[i].ItemType = ciFolder then
        if tmpItems.Items[i].FileName = cFolderPhoto then
        begin
          nci := tmpItems.Items[i];
          break;
        end;
    end;

    if nci <> NIL then
    begin
      tmpFotos := Storage.GetFolderList(nci);  // <- Problem
    
      if tmpFotos <> NIL then
      begin
        for i := 0 to tmpItems.Count-1 do
        begin
          // ....
        end;

      end;
    end;

Can you tell me what's wrong?

With SearchList() it works, but I need the GetFolderList() function, because I can't search with asteriks * to get all files....

Hi,

Calling GetFolderList the second time would remove the references to the result of the first call to GetFolderList.

There are two possible alternatives:

  • Create a new TDropBoxItem object and assign the ID and Path values manually. Then use the TDropBoxItem as the parameter in the GetFolderList call.

  • Use GetFolderListHierarchical instead.
    This will fill up the Drive collection property hierarchically.