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;

 slPastas : TStringList;
 z,i: integer;
 ci, ciPasta:TCloudItem;
 achou: boolean;
     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

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

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



Any suggestion ?


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.