任何人都可以幫我解決一些疑惑嗎? 如何從按鈕調用此公共共享功能?以及如何在datagridview中顯示「結果」(文件列表)? 謝謝。VB網絡:如何調用這個公共共享函數?
Imports System.Threading
Imports System.Threading.Tasks
Imports Google.Apis.Auth.OAuth2
Imports Google.Apis.Drive.v2
Imports Google.Apis.Drive.v2.Data
Imports Google.Apis.Services
Imports System.Net
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'?
End Sub
Public Shared Function retrieveAllFiles(service As DriveService) As List(Of File)
Dim Secrets = New ClientSecrets()
Secrets.ClientId = "CLIENT ID"
Secrets.ClientSecret = "CLIENT SECRET"
Dim scope = New List(Of String)
scope.Add(DriveService.Scope.Drive)
Dim credential = GoogleWebAuthorizationBroker.AuthorizeAsync(Secrets, scope, "USER", CancellationToken.None).Result()
Dim initializer = New BaseClientService.Initializer
initializer.HttpClientInitializer = credential
initializer.ApplicationName = "APPLICATION NAME"
Dim service = New DriveService(initializer)
Dim request As FilesResource.ListRequest = service.Files.List()
Dim result As New List(Of File)()
Dim request As FilesResource.ListRequest = service.Files.List()
Do
Try
Dim files As FileList = request.Execute()
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
End Function
End Class
告訴你如何使用它,那** **是相關代碼 – Plutonix 2014-09-04 13:46:59
yourclassname.retrieveAllFiles(...) – Arvo 2014-09-04 13:56:52