List all Files and Folders from Google Drive V2 using .Net

六眼飞鱼酱① 提交于 2019-12-10 17:31:14

问题


I am creating an application using Google Drive API in .Net using the Google API .Net client library.

In that list request get all files from root folder as well as from child folders and shared files. I don't want to list them all. I want list of files which are available in root folders only, not from sub folders. Hows that possible?

My code is below :

 FilesResource.ListRequest listRequest = service.Files.List();
 var files = listRequest.Execute();

for that I have define scope as

var Scopes = { DriveService.Scope.Drive };

回答1:


files.list has an optional parpamter called q its used for searching

q string Query string for searching files. See Searching for files for more information about supported fields and operations.

FilesResource.ListRequest listRequest = service.Files.List();
listRequest.Q = "'root' in parents";
var files = listRequest.Execute();

Would just list things within the root directory with out the children. I suggest you check the documentation on search it goes though how to use it.



来源:https://stackoverflow.com/questions/42621948/list-all-files-and-folders-from-google-drive-v2-using-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!