如果您需要下载分页,也可以通过C#SDK来实现。诀窍在于跟踪listRequest.Execute()返回值,该返回值包含多个变量以及它们之间的NextPageToken。在标准google示例中,这部分是“隐藏的” 。
FilesResource.ListRequest listRequest = _service.Files.List(); listRequest.PageSize = 100; listRequest.Fields = "nextPageToken, files(id, name)"; // List files. var result = listRequest.Execute(); IListfiles =result.Files; Console.WriteLine("Files:"); while (files!=null && files.Count > 0) { foreach (var file in files) { Console.WriteLine("{0} ({1})", file.Name, file.Id); } if (!string.IsNullOrWhiteSpace(result.NextPageToken)) { listRequest = _service.Files.List(); listRequest.PageToken = result.NextPageToken; listRequest.PageSize = 100; listRequest.Fields = "nextPageToken, files(id, name)"; result = listRequest.Execute(); files = result.Files; } }