Google Drive Api创建文件夹错误

时间:2014-04-30 10:05:50

标签: c# google-drive-api

我正在创建一个google drive c#应用程序,我遇到了一个我不知道如何解决的错误。当我尝试创建一个文件夹时,我收到以下错误:

  

无法隐式转换类型   'Google.Apis.Drive.v2.FilesResource.InsertRequest'来   'Google.Apis.Drive.v2.FilesResource.InsertMediaUpload'

以下是代码:

File body = new File();
body.Title = "NewFolder";
body.Description = "testtest";
body.MimeType = "application/vnd.google-apps.folder";
// service is an authorized Drive API service instance

FilesResource.InsertMediaUpload request = service.Files.Insert(body);
request.Upload();
File file = request.ResponseBody;

2 个答案:

答案 0 :(得分:0)

您正尝试将媒体上传到文件夹。文件夹没有媒体,所以你想做的事情毫无意义。

答案 1 :(得分:0)

请改用此var或FilesResource.InsertMediaUpload:

File body = new File();
body.Title = "NewFolder";
body.Description = "testtest";
body.MimeType = "application/vnd.google-apps.folder";
// service is an authorized Drive API service instance


var request = service.Files.Insert(body);
request.Upload();
File file = request.ResponseBody;