How do I handle the simulated folder structure using the GDrive component?

Google Drive doesn't have a folder structure, but does simulate such an environment. You can access an object's "parents" and "children" as query parameters in order to navigate/access the files in such a simulated structure.

Date Entered: 04/08/2014    Last Updated: 03/13/2017

Below you'll see options for listing subfolders and files within a folder/subfolder.

Query for only subfolders of the root gdrive1.ResourceIndex = -1; //Clear the Document properties. gdrive1.AddQueryParam("q", "'root' in parents"); //Do not include files gdrive1.Config("IncludeFiles=false"); gdrive1.ListResources(); for (int i = 0; i < gdrive1.ResourceCount; i++) { gdrive1.ResourceIndex = i; Console.WriteLine(gdrive1.ResourceName + "(" + gdrive1.ResourceId + ")"); }

Query for only subfolders of a specific folder String resourceId = //retrieve the ResourceId of the specific folder gdrive1.ResourceIndex = -1; //Clear the Document properties. gdrive1.AddQueryParam("q", "'" + resourceId + "' in parents"); //Do not include files gdrive1.Config("IncludeFiles=false"); gdrive1.ListResources(); for (int i = 0; i < gdrive1.ResourceCount; i++) { gdrive1.ResourceIndex = i; Console.WriteLine(gdrive1.ResourceName + "(" + gdrive1.ResourceId + ")"); }

Query for documents at the root, not including any folders gdrive1.ResourceIndex = -1; //Clear the Document properties. gdrive1.AddQueryParam("q", "'root' in parents AND mimeType != 'application/vnd.google-apps.folder'"); gdrive1.ListResources(); for (int i = 0; i < gdrive1.ResourceCount; i++) { gdrive1.ResourceIndex = i; Console.WriteLine(gdrive1.ResourceName + "(" + gdrive1.ResourceId + ")"); }

Query for documents within a specific folder, not including any folders String resourceId = //retrieve the ResourceId of the specific folder gdrive1.ResourceIndex = -1; //Clear the Document properties. gdrive1.AddQueryParam("q", "'" + resourceId + "' in parents AND mimeType != 'application/vnd.google-apps.folder'"); gdrive1.ListResources(); for (int i = 0; i < gdrive1.ResourceCount; i++) { gdrive1.ResourceIndex = i; Console.WriteLine(gdrive1.ResourceName + "(" + gdrive1.ResourceId + ")"); }


We appreciate your feedback.  If you have any questions, comments, or suggestions about this entry please contact our support team at kb@nsoftware.com.