1
FilesResource.ListRequest list = DriveService.Files.List();
list.Q = "mimeType = 'application/vnd.google-apps.folder' and trashed = false";
list.MaxResults = 500;
FileList folders = list.Fetch<FileList>();

Above piece of code returns all folders but my requirement is to get only orphan folders which are at same level of 'My Drive' and 'Shared with me'.

I could do a looping through each folder based on "folder.Parents.Count == 0" condition but it is too expensive for me. Does any one know to get only orphan components by using Google Drive query?

Jeevan
  • 167
  • 2
  • 11

1 Answers1

0

Im assuming that when you say 'My Drive' you mean root.

try adding in parents to your query. It will return only the results with in that directory.

 list.Q = "mimeType='application/vnd.google-apps.folder' and trashed=false and 'root' in parents ";
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Thanks for your response. This query return folders present inside 'My Drive' only , but in Google Drive, you can make orphan folders, which you can see only in 'All Items' view of Google Drive. So,I want such folders which are not present in 'My Drive' and 'Shared with me' folder hierarchy. – Jeevan Apr 01 '14 at 10:02