vb.net可以';我不能在谷歌硬盘上传我的文件

vb.net可以';我不能在谷歌硬盘上传我的文件,vb.net,file-upload,google-docs-api,Vb.net,File Upload,Google Docs Api,我正在使用google drive api上传pdf文件(使用vb.net),我在这个网站和另一个网站上搜索了很多教程(如何在vb.net中获得google drive api,如何上传…),最后我成功地完成了 但问题是,驱动器中没有添加任何文件 这是我的密码 Private Sub btn_save_Click(sender As Object, e As EventArgs) Handles btn_save.Click Dim filename As String = fichie

我正在使用google drive api上传pdf文件(使用vb.net),我在这个网站和另一个网站上搜索了很多教程(如何在vb.net中获得google drive api,如何上传…),最后我成功地完成了 但问题是,驱动器中没有添加任何文件

这是我的密码

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
当我执行应用程序时,结果是


但我在驱动器中找不到任何文件

您两次调用CreateService(),但从未使用它上载任何内容

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)
    '' ---------------------------------------------------------
    '' Here you'll going to use the service to upload your data
    '' with Service.Files.Create()
    '' ---------------------------------------------------------
    Me.Cursor = Cursors.Default
    MsgBox("Upload Finished")
End Sub

insert不是fileresourceFixed的成员,是v2 API和v3您将使用的文件。Create()我被卡住了,我如何使用它(给我一个例子)我使用了v2 API,我添加了Dim文件作为新的Google.API.Drive.v2.Data.File()文件。Title=“我的文档”文件。Description=“document”文件。MimeType=“text/plain”调暗为fileResource.InsertMediaUpload=Service.Files.Insert(文件,流,文件.MimeType),但结果相同我找到了一个解决方案,我添加了这个:Up.upload(),结果就完成了,但是当我想查看文件时,我无法查看,因为文件已加密