【发布时间】:2015-04-14 13:38:41
【问题描述】:
我正在尝试通过 Google API 返回我的 Google 驱动器中的文件列表。一切正常,只是它不断返回一长串 google.apis.drive.v2.data.file 而不是实际文件。我的代码可能有问题,但我不确定。感谢您的帮助!
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim bob As New GoogleDrive
Dim joe As New DriveModifyDate
Dim items As String = String.Join(Environment.NewLine, joe.GetFiles(bob.service, ""))
MsgBox(items)
我用它来调用这段代码。
Public Function GetFiles(ByVal service As DriveService, ByVal search As String) As IList(Of File)
Dim Files As IList(Of File) = New List(Of File)
Try
'List all of the files and directories for the current user.
Dim list As FilesResource.ListRequest = service.Files.List
list.MaxResults = 1000
If (Not (search) Is Nothing) Then
list.Q = search
End If
Dim filesFeed As FileList = list.Execute
'/ Loop through until we arrive at an empty page
While (Not (filesFeed.Items) Is Nothing)
' Adding each item to the list.
For Each item As File In filesFeed.Items
Files.Add(item)
Next
' We will know we are on the last page when the next page token is
' null.
' If this is the case, break.
If (filesFeed.NextPageToken Is Nothing) Then
Exit While
End If
' Prepare the next page of results
list.PageToken = filesFeed.NextPageToken
' Execute and process the next page request
filesFeed = list.Execute
End While
Catch ex As Exception
' In the event there is an error with the request.
MsgBox(ex.Message)
End Try
Return Files
End Function
【问题讨论】:
标签: vb.net list google-app-engine google-drive-api