Thru the below code, I can able to fetch 1000 records but I have totally 6500++ records in my drive. Searching google but unable to find out the correct solution.
As per reference, the description value of Parameter "pageSize" is "The maximum number of files to return per page. Acceptable values are 1 to 1000, inclusive. (Default: 100)".
So it means, we can get only 1000 records or if possible, then what's the way. Also, I dont understand about the Parameter "pageToken", wats the usage of 'nextPageToken' value in realtime.
Can anyone please help me out.
namespace gDrive
{
class Program
{
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/drive-dotnet-quickstart.json
static string[] Scopes = { DriveService.Scope.DriveReadonly };
static string ApplicationName = "Drive API .NET Quickstart";
static void Main(string[] args)
{
UserCredential credential;
gDriveTableAdapter gDrive = new gDriveTableAdapter();
using (var stream =
new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/drive-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
//Console.WriteLine("Credential file saved to: " + credPath);
}
// Create Drive API service.
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
// Define parameters of request.
FilesResource.ListRequest listRequest = service.Files.List();
listRequest.PageSize = 1000;
listRequest.Fields = "nextPageToken, files(webViewLink, name)";
// List files.
IList<Google.Apis.Drive.v3.Data.File> files = listRequest.Execute()
.Files;
Console.WriteLine("Processing...\n");
if (files != null && files.Count > 0)
{
foreach (var file in files)
{
gDrive.InsertQuery(file.Name, file.WebViewLink);
}
Console.WriteLine(files.Count + " records fetched.");
}
else
{
Console.WriteLine("No files found.");
}
Console.Read();
}
}
}