我想在谷歌硬盘中添加新文件夹 我使用这段代码:
Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
body.Title = "title";
body.Description = "description";
body.MimeType = "application/vnd.google-apps.folder";
byte[] byteArray = Encoding.ASCII.GetBytes(content);
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
Google.Apis.Drive.v2.FilesResource.InsertMediaUpload request =
service.Files.Insert(body, stream, mimeType);
Google.Apis.Drive.v2.Data.File parentFolder = request.Upload();
符合代码:
request.Upload()
我收到以下错误消息:您无法将内容上传到application / vnd.google-apps.folder
答案 0 :(得分:0)
问题在于这一行
Google.Apis.Drive.v2.FilesResource.InsertMediaUpload request =
service.Files.Insert(body, stream, mimeType);
你应该做一个简单的插入。通过调用InsertMediaUpload,您告诉驱动器您正在尝试将某些内容上传到Folder实体,这当然没有意义。