List All files on Google drive 5

Please Share

google drive I recently ran across a question on Stack overflow. The question was quite simple how to retrieve the folder values of from Google drive and display them in a directory list using C# and the Google .Net client library.

I have used a PageStreamer in the ListAll method in the event that there are more then 1000 files in the directory this will ensure that we get them all back. PageStreaming is much easier then having to deal with the nextPageToken yourself.

After we have all of the results then PrettyPrint is running recursively to request all of the files from within any directories.


By using PageStreamer you can retrieve all of the rows for your request rather then having to worry about the nextPageToken yourself.

Note: I am not responsible for the usage of your quota if you print everything 🙂

Please Share

Linda Lawton

About Linda Lawton

My name is Linda Lawton I have more than 20 years experience working as an application developer and a database expert. I have also been working with Google APIs since 2012 and I have been contributing to the Google .Net client library since 2013. In 2013 I became a a Google Developer Experts for Google Analytics.

Leave a comment

Your email address will not be published. Required fields are marked *

5 thoughts on “List All files on Google drive

  • Marcel Talamini

    Hi Linda,
    Thanks for all your examples and explanations. It helped me a lot.

    I have a question.
    I have up to 3000 files on my Drive (service account).

    I have to show some kind of Explorer with the files and folders.
    What would you recommend?
    Read all files at startup and populate the explorer with the result. or
    Build the explorer on demand from root. Which could result in more request.

    Do I need to build an Exponential Backoff, when using the “PageStreamer”?


    • Linda Lawton
      Linda Lawton Post author

      Do I need to build an Exponential Backoff, when using the “PageStreamer”?

      The client library has built in support for back-off. You shouldn’t need to worry about it, we have it taken care of.

      Explorer with the files and folders.

      There is a few things you need to consider with this. The first being memory. Whatever you return there needs to be enough memory in your system to hold the object. Currently you only have 3000 files which shouldnt be a problem just requesting them all in the start and using them as you go. If you start to get more files and things begin to slow down you may have to revisit it.

  • Srusti Thakkar

    I want to list files which are owned by that particular user only, not shared with user. What scope I have to set?