我怎么能把它放在两个Vb网按钮 [英] How Can I Put This In Two Vb Net Buttons

查看:90
本文介绍了我怎么能把它放在两个Vb网按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。



我希望你能帮助我。我不知道如何把这个代码放在两个VB网络按钮(Get& Download)中,这个代码是谷歌驱动器API的一个样本,从我的谷歌驱动器帐户获取和下载我的文件,文件不是嘟嘟很清楚,因为我是新的apis世界。



Hi everyone.

I hope you can help me. I dont know how to put this code in two VB net buttons (Get & Download), this code its a sample for google drive api to "Get" and "Download" my files from my google drive account, the documentation its not toot clear for me because im new in apis world.

Imports Google.Apis.Authentication
Imports Google.Apis.Drive.v1
Imports Google.Apis.Drive.v1.Data

Imports System.Net
' ...

Public Class [MyClass]

	' ...

	''' <summary>
	''' Print a file's metadata.
	''' </summary>
	''' <param name="service">Drive API service instance.</param>
	''' <param name="fileId">ID of the file to print metadata for.</param>
	Public Shared Sub printFile(service As DriveService, fileId As [String])
		Try
			Dim file As File = service.Files.[Get](fileId).Execute()

			Console.WriteLine("Title: " + file.Title)
			Console.WriteLine("Description: " + file.Description)
			Console.WriteLine("MIME type: " + file.MimeType)
		Catch e As Exception
			Console.WriteLine("An error occurred: " + e.Message)
		End Try
	End Sub

	''' <summary>
	''' Download a file and return a string with its content.
	''' </summary>
	''' <param name="authenticator">
	''' Authenticator responsible for creating authorized web requests.
	''' </param>
	''' <param name="file">Drive File instance.</param>
	''' <returns>File's content if successful, null otherwise.</returns>
	Public Shared Function DownloadFile(authenticator As IAuthenticator, file As File) As System.IO.Stream
		If Not [String].IsNullOrEmpty(file.DownloadUrl) Then
			Try
				Dim request As HttpWebRequest = authenticator.CreateHttpWebRequest("GET", New Uri(file.DownloadUrl))
				Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
				If response.StatusCode = HttpStatusCode.OK Then
					Return response.GetResponseStream()
				Else
					Console.WriteLine("An error occurred: " + response.StatusDescription)
					Return Nothing
				End If
			Catch e As Exception
				Console.WriteLine("An error occurred: " + e.Message)
				Return Nothing
			End Try
		Else
			' The file doesn't have any content stored on Drive.
			Return Nothing
		End If
	End Function

	'...

End Class

推荐答案

请参阅我对该问题的评论。也许你找不到那么少,因为你没有搜索正确的术语。它被称为Google Drive SDK。您会找到大量示例,例如: https://developers.google.com/drive/web/ quickstart / quickstart-cs [ ^ ]。



如果你想获得良好的.NET帮助,你真的需要了解至少一些C#;你不能指望VB.NET这么多帮助,因为更好的开发人员大多喜欢C#,这与VB.NET不同,是标准化的; 2)是微软的旗舰产品,因此微软人士更加认真地对待它并首先在C#中实施创新。



要在两者之间自动翻译,请查看我过去的答案:

代码解释, C#到VB.NET [ ^ ],

需要将vb代码转换为c# [ ^ ]。



-SA
Please see my comments to the question. Perhaps you found less then you could because you did not search for right terms. It's called "Google Drive SDK". You will find plenty of samples, for example: https://developers.google.com/drive/web/quickstart/quickstart-cs[^].

You really need to understand at least some C#, if you want good .NET help; you cannot count on so much help with VB.NET along, because better developers mostly prefer C#, which is, unlike VB.NET is 1) standardized; 2) is a Microsoft flagship, so Microsoft people take it more seriously and implement innovation first in C#.

To auto-translate between the two, please see my past answers:
Code Interpretation, C# to VB.NET[^],
Need to convert vb code to c#[^].

—SA


这篇关于我怎么能把它放在两个Vb网按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆