Question

I have a vb.net app to access Drive. I have everything working except listing files INSIDE a folder. I need to pass a folder ID from the UI and show the files within.

I have read other answers e.g. (Getting a list of files by folder on Drive SDK) which state using a "q" param appended to a GET URL but I am not building the GET URL. I cannot see how to pass Q param when running ListRequest below:

This returns a file list fine from the ROOT, but how to pass Q into it to return files from a specified folder:

    Dim result As New List(Of File)()
        Dim request As FilesResource.ListRequest = service.Files.List()

        Do
            Try
                Dim files As FileList = request.Fetch()
                result.AddRange(files.Items)
                request.PageToken = files.NextPageToken
            Catch e As Exception
                Console.WriteLine("An error occurred: " + e.Message)
                request.PageToken = Nothing
            End Try
        Loop While Not [String].IsNullOrEmpty(request.PageToken)
        Return result

I need to pass an ID like "0B_p57qQpdddyl8nR0NBT3hXQUdIRFE in parents". The PHP example in the docs shows adding paramters inside the service.files.list() method, but there are no overloads in the .NET version and so I have no idea how to add the filter....

I can run:

    Dim request As ChildrenResource.ListRequest = service.Children.List(folderid)

Passing in folderID and then:

    Dim files As ChildList = request.Fetch()

But this doesn't return a list of files like the first function, but just the child files' ID meaning i'd have to then do an individual file request for each blah blah.

Can anyone help? Thanks.

Was it helpful?

Solution

The ListRequest object has a Q property that you can set:

Dim request As FilesResource.ListRequest = service.Files.List()
request.Q = "'0B_p57qQpdddyl8nR0NBT3hXQUdIRFE' in parents"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top