0

我在使用VB.net Express 2012连接到我的Google Drive时遇到问题。 它支持它吗?Google Drive with VBnet Express

Imports Google.Apis.Auth.OAuth2 
Imports Google.Apis.Drive.v2 
Imports Google.Apis.Drive.v2.Data 
Imports Google.Apis.Services 
Imports Google.Apis.Util.Store 
Imports System.Collections.Generic 
Imports System.IO 
Imports System.Linq 
Imports System.Text 
Imports System.Threading 
Imports System.Threading.Tasks 

Namespace DriveQuickstart 
    Class Program 
     Shared Scopes As String() = {DriveService.Scope.DriveReadonly} 
     Shared ApplicationName As String = "Drive API .NET Quickstart" 

     Private Shared Sub Main(args As String()) 
      Dim credential As UserCredential 

      Using stream = New FileStream("client_secret.json", FileMode.Open, FileAccess.Read) 
       Dim credPath As String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) 
       credPath = Path.Combine(credPath, ".credentials/drive-dotnet-quickstart") 

       credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, New FileDataStore(credPath, True)).Result 
       Console.WriteLine(Convert.ToString("Credential file saved to: ") & credPath) 
      End Using 

      ' Create Drive API service. 
      Dim service = New DriveService(New BaseClientService.Initializer() With { _ 
       Key .HttpClientInitializer = credential, _ 
       Key .ApplicationName = ApplicationName _ 
      }) 

      ' Define parameters of request. 
      Dim listRequest As FilesResource.ListRequest = service.Files.List() 
      listRequest.MaxResults = 10 

      ' List files. 
      Dim files As IList(Of Google.Apis.Drive.v2.Data.File) = listRequest.Execute().Items 
      Console.WriteLine("Files:") 
      If files IsNot Nothing AndAlso files.Count > 0 Then 
       For Each file As var In files 
        Console.WriteLine("{0} ({1})", file.Title, file.Id) 
       Next 
      Else 
       Console.WriteLine("No files found.") 
      End If 
      Console.Read() 

     End Sub 
    End Class 
End Namespace 

我跑的NuGet中失败的控制台上,所以我不得不把DLL的手动复制到项目并添加他们作为参考,其显示为Imports google.*不给错误了工作,但我得到代码中的错误。

enter image description here

任何帮助吗?

更新

我认为这个问题可能是我使用vbnet表示2012 作为对https://developers.google.com/drive/web/quickstart/dotnet它说: 先决条件

要运行这个快速入门,你将需要:

Visual Studio 2013或更高版本。

有什么解决办法吗?

UPDATE2

我不再需要这个代码,我会用不同的方法 随时与别人有同样的问题

+0

我在VS 2010中使用.NET客户端库,这样是不正确的。我知道的唯一先决条件是它需要.net framework 4.0或4.5。 – DaImTo

+0

哪个块金包确实导入了? – DaImTo

+0

所有4 dll文件从portable-net40 + sl50 + win + wpa81 + wp80(Google.Apis.Auth.dll,Google.Apis.Core.dll,Google.Apis.dll,Google.Apis.Drive.v2.dll) –

回答

0

对于VAR错误回答,看起来像C# 。 将其替换为Google.Apis.Drive.v2.Data.File,或者可能只是将文件导入。

与Google.Apis.Util.Store.FileDataStore

您还没有初始化 '服务' 正确更换Filedatastore。再次,这看起来更像c#。 使用类似: 昏暗的服务为新... 参见:https://msdn.microsoft.com/en-us/library/bb531244.aspx