Reputation: 23
Is there a way to determine if the folder is shared Drive folder or not with Google Drive API?
Following is the code I am using to check this:
DriveService service = GetService();
var request = service.Files.List();
request.IncludeTeamDriveItems = true;
request.SupportsTeamDrives = true;
IList<File> listFiles = request.Execute().Files;
if (listFiles != null && listFiles.Count > 0)
{
foreach (var file in listFiles)
{
if(file.TeamDriveId == aIdFolder)
{
//Yes It's a shared drive folder
}
}
}
Please advise.
Upvotes: 1
Views: 274
Reputation: 68
Proposed solution works for me:
var listFiles = ListAllFiles(service).Files;
if (listFiles != null && listFiles.Count > 0)
{
foreach (var file in listFiles)
{
if (file.Id == aIdFolder && !String.IsNullOrWhiteSpace(file.TeamDriveId))
{
//here your result
return true;
}
}
}
Upvotes: -1
Reputation: 116968
If you check the file response.
check the driveid property
I suspect that it would be the same if its a directory thats on a shared drive. I dont have access to a drive now. Let me know if it doesnt work.
Upvotes: 2