所有的代码运行没有错误,但当我检查我的谷歌云端硬盘帐户我找不到我上传的文件(“document.txt”)。无法上传文件到谷歌驱动器 - 使用c#
此外它又要求我再次进行身份验证。
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "Here my clientid",
ClientSecret = "client secret",
},
new[] { DriveService.Scope.Drive },
"user",
CancellationToken.None).Result;
// Create the service.
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Drive API Sample",
});
File body = new File();
body.Title = "My document";
body.Description = "A test document";
body.MimeType = "text/plain";
byte[] byteArray = System.IO.File.ReadAllBytes("document.txt");
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "text/plain");
request.Upload();
File file = request.ResponseBody;
问题: 为什么不能找到我上传的文件,我怎么能得到它记住我的身份验证。
感谢您的回复。 我会做建议的变化 – 2014-12-03 11:51:36
你可以找到示例项目沿着这里https://github.com/LindaLawton/Google-Dotnet-Samples/tree/master/Google-Drive – DaImTo 2014-12-03 11:57:03
伟大的教程。让我检查一下。 – 2014-12-03 11:59:43