【发布时间】:2014-11-13 04:13:35
【问题描述】:
我正在尝试使用 C# .net 从谷歌驱动器下载文件。我正在使用来自https://developers.google.com/drive/web/manage-downloads的示例代码
代码未编译并给出 IAuthenticator 定义错误
error CS0234: The type or namespace name 'Authentication' does not exist in the namespace 'Google.Apis' (are you missing an assembly reference?)
error CS0246: The type or namespace name 'IAuthenticator' could not be found (are you missing a using directive or an assembly reference?)
using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v2;
using Google.Apis.Drive.v2.Data;
using Google.Apis.Services;
using Google.Apis.Authentication;
public static System.IO.Stream DownloadFile(
IAuthenticator authenticator, File file) {
我也试过了
service.Files.Get(fileId).Download(myFileStream);
但是,这会导致“文件已被进程使用”的错误
有没有人成功使用 C# 示例下载文件?
PS:我已经安装了所需的 nuget 包
PM> install-package Google.Apis.Auth
Attempting to resolve dependency 'Google.Apis.Core (≥ 1.9.0)'.
Attempting to resolve dependency 'Microsoft.Bcl (≥ 1.1.9)'.
Attempting to resolve dependency 'Microsoft.Bcl.Build (≥ 1.0.14)'.
Attempting to resolve dependency 'Microsoft.Bcl.Async (≥ 1.0.168)'.
Attempting to resolve dependency 'Microsoft.Net.Http (≥ 2.2.22)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 6.0.4)'.
'Google.Apis.Auth 1.9.0' already installed.
GoogleDrive already has a reference to 'Google.Apis.Auth 1.9.0'.
【问题讨论】:
-
你能告诉我们你到底有什么吗?您包含的所有名称空间是什么?您是否使用命名空间进行身份验证? OAuth?
-
这是我所拥有的:使用 Google.Apis.Auth.OAuth2;使用 Google.Apis.Download;使用 Google.Apis.Drive.v2;使用 Google.Apis.Drive.v2.Data;使用 Google.Apis.Services;
-
您在哪一行收到此错误。您能否粘贴整个异常详细信息。包括行号和堆栈跟踪..
-
在原始问题中添加了详细信息。
-
实际上你在更新版本中没有这个
Interface检查given link 中的过时评论.. 此代码不适用于最新的 dll.. 你必须使用等效的类.. 检查这里有一个样本stackoverflow.com/questions/23883379/…
标签: c# google-drive-api