I've got an app that communicates with Drive (specifically TeamDrives) and I need to pull a hierarchical folder structure within a given TeamDrive.
I can list my available TeamDrives then get the files (filter: folders mime type) within them but there doesn't seem to be any parent
info to each folder so my structure is seemingly 'flat'.
I get that on Drive a folder is just a label and that 'sub-folders' could be shared in several places so I will cater for that but I just want to be able to create the directory tree on my app.
e.g. structure as I want to show it in my app:
- Team Drive Name
- Main Folder
- Sub Folder
- Main Folder
My 'list' code:
var request = service.Files.List();
request.Corpora = "teamDrive";
request.IncludeTeamDriveItems = true;
request.SupportsTeamDrives = true;
request.OrderBy = "name";
request.PageSize = 100;
request.TeamDriveId = "[teamDriveId]";
request.Q = "mimeType='application/vnd.google-apps.folder'";
This gives me for a given 'teamDriveId':
- Main Folder
- Sub Folder
parent
on the Sub Folder
result is null
.