VB.Net和谷歌驱动器sdk

时间:2012-11-23 14:04:53

标签: vb.net google-drive-api

我在VB.Net中有一个应用程序,可以在google doc上下载和上传文档。 但现在谷歌文档已成为谷歌驱动器。

我使用此代码连接到我的帐户。


Public Class Form1
    Dim DocServices As DocumentsService

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    logIn()
End Sub

Sub logIn()
    DocServices = New DocumentsService("DocListUploader")
    DocServices.setUserCredentials(txtUserName.Text, txtPassword.Text)

    Dim docQuery As New DocumentsListQuery
    docQuery.NumberToRetrieve = 1
    DocServices.Query(docQuery)
    getDocList()
End Sub



Sub getDocList()
    Me.lbDocs.Items.Clear()
    Dim resultFeed As DocumentsFeed = Me.theFeed()
    Dim entry As New DocumentEntry
    For Each entry In resultFeed.Entries
        Me.lbDocs.Items.Add(entry.Title.Text)
    Next
End Sub

Function theFeed() As DocumentsFeed
    Dim query As New DocumentsListQuery()
    Dim feed As DocumentsFeed = DocServices.Query(query)
    Return feed
End Function

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
        Dim theFilename As String = OpenFileDialog1.FileName
        Dim theEntry As DocumentEntry
        theEntry = DocServices.UploadDocument(theFilename, Nothing)
    End If
End Sub
End Class

我想做同样的想法,但谷歌驱动器。我在vb.net中找不到只在c#中this的代码。 请帮帮我。

1 个答案:

答案 0 :(得分:0)

您的代码仍然有效。文档列表API不会停止使用,并且会在Google云端硬盘上访问您的文件。

我不知道VB中是否存在Drive API的实现,如果您真的想要使用Drive API,则可能需要手动构建HTTP请求