-1
我使用谷歌驅動器api上傳PDF文件(與vb.net),我搜索了很多教程在這個和另一個網站(如何獲得谷歌驅動器API在vb.net中,如何上傳...),最後我已經成功做到了 但問題,沒有文件在傳動vb.net無法上傳我的文件在谷歌驅動器
這裏加入是我的代碼
Private Sub btn_save_Click(sender As Object, e As EventArgs) Handles btn_save.Click
Dim filename As String = fichier.FileName 'from selected file in openfiledialog
CreateService()
UploadFile(filename)
End Sub
Private Service As DriveService = New DriveService
Private Sub CreateService()
Dim ClientId = "*********"
Dim ClientSecret = "****************"
Dim MyUserCredential As UserCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets() With {.ClientId = ClientId, .ClientSecret = ClientSecret}, {DriveService.Scope.Drive}, "user", CancellationToken.None).Result
Service = New DriveService(New BaseClientService.Initializer() With {.HttpClientInitializer = MyUserCredential, .ApplicationName = "Google Drive VB Dot Net"})
End Sub
Private Sub UploadFile(FilePath As String)
Me.Cursor = Cursors.WaitCursor
CreateService()
Dim ByteArray As Byte() = System.IO.File.ReadAllBytes(FilePath)
Dim Stream As New System.IO.MemoryStream(ByteArray)
Me.Cursor = Cursors.Default
MsgBox("Upload Finished")
End Sub
當我執行我的應用程序,結果是
但我找不到驅動器中的任何文件
插入不固定fileresource –
的一員,與V3將使用Files.Create() –
我很堅持,我如何使用它V2 API(舉個例子) –