Create structure folders

I"m trying to create a method where I can pass a string with a folder structure to be created from GOOGLE DRIVE.

I"m using TAdvGDRIVE = Storage object

The method would seem to be simple, I"ll send the structure as the following example:

Create Folder Structure ("\ Folder1\ subs-folder1\ test1")

The first folder is created normally but from 2a an error occurs.

Invalid class typecast

function CriarEstruturaPastas(sPasta:string):TCloudItem;

var
 slPastas : TStringList;
 z,i: integer;
 ci, ciPasta:TCloudItem;
 cisPesquisa:TCloudItems;
 achou: boolean;
begin
 try
   try
     slPastas := TStringList.Create;

     slPastas.Delimiter := "";

     slPastas.StrictDelimiter := true;

     slPastas.DelimitedText := sPasta;

     if slPastas[0]="" then slPastas.Delete(0);

     Result :=nil;
    for z:=0 to slPastas.Count-1 do
    begin
        achou:=false;

        cisPesquisa:=Storage.SearchList(slPastas[z], True, Result);
         if (cisPesquisa<>nil) and (cisPesquisa.Count>0) then
         begin
           for i := 0 to cisPesquisa.Count-1 do
           begin
              ci:=TCloudItem( cisPesquisa.Items );
              if (ci.ItemType = ciFolder) AND
                 (ci.FileName = slPastas[z] )
              then
              begin
                 Result:= ci;
                 Achou:=True;
                 Break;
              end;
           end;
        end;

        if not achou then
              Result:=storage.CreateFolder(Result, slPastas[z]);
    end;
   except
     on E:Exception do
     begin
        Exception.RaiseOuterException( Exception.Create("[CriarEstruturaPastas]"));
     end;
   end;

 finally

 end;
end;

Any suggestion ?

Hi,


We are currently investigating this issue and will report back as soon as possible.

Still investigating??????? 

Unfortunately due to the high workload caused by several ongoing projects we haven't been able to allocate sufficient time to investigate this issue.
As soon as time permits we'll have a look at this.