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


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 article please contact our support team at support@nsoftware.com.