gpt4 book ai didi

c# - BaseClientService 不包含文件的定义

转载 作者:太空宇宙 更新时间:2023-11-03 12:45:51 29 4
gpt4 key购买 nike

我在使用来自 google Nuget 包 (Google.Apis.Drive.v3) 的 DriveService 时遇到问题。

我收到这个错误:

Severity Code Description Project File Line Suppression State Error CS1061 'BaseClientService' does not contain a definition for 'Files' and no extension method 'Files' accepting a first argument of type 'BaseClientService' could be found (are you missing a using directive or an assembly reference?) Sampleproject.Web C:\sample\Sampleproject.Web\Controllers\DriveController.cs 117 Active

enter image description here

我正在使用官方文档中的部分指南:https://developers.google.com/drive/v3/web/quickstart/dotnet#step_1_turn_on_the_api_name

最初我认为这只是我缺少的“用法”,但我似乎无法弄清楚/谷歌我的方法。

编辑:

我的服务是这样的: enter image description here

我的用户凭证如下所示: enter image description here

最佳答案

我不确定您是如何创建服务的,但您可以尝试:

我猜你正在做这样的事情。

// Create Drive API service.
var service = new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Drive Authentication Sample",
};

在这种情况下,您应该像这样声明服务。

// Create Drive API service.
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Drive Authentication Sample",
});

更新:

部分问题可能是您混合使用了 V2 和 V3。

using Google.Apis.Drive.v3;

列表:

var pageStreamer = new PageStreamer<Google.Apis.Drive.v3.Data.File, FilesResource.ListRequest, Google.Apis.Drive.v3.Data.FileList, string>(
(request, token) => request.PageToken = token,
response => response.NextPageToken,
response => response.Files);

var req = service.Files.List();
req.PageSize = 1000;


foreach (var result in pageStreamer.Fetch(req))
{
Console.WriteLine(result.Id);
}

关于c# - BaseClientService 不包含文件的定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37347422/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com