【发布时间】:2018-08-10 16:43:42
【问题描述】:
我正在尝试通过 c# 从谷歌驱动器下载文件。但是每次我运行下载文件的代码但我无法下载它。 这是我的下载代码:
private static void DownloadFile(Google.Apis.Drive.v3.DriveService driveService)
{
var fileId = "//my file id for file on drive";
var request = driveService.Files.Get(fileId);
var stream = new System.IO.MemoryStream();
// Add a handler which will be notified on progress changes.
// It will notify on each chunk download and when the
// download is completed or failed.
request.MediaDownloader.ProgressChanged +=
(IDownloadProgress progress) =>
{
try
{
switch (progress.Status)
{
case DownloadStatus.Downloading:
{
Console.WriteLine(progress.BytesDownloaded);
break;
}
case DownloadStatus.Completed:
{
Console.WriteLine("Download complete.");
break;
}
case DownloadStatus.Failed:
{
Console.WriteLine("Download failed.");
break;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
};
request.Download(stream);
}
【问题讨论】:
-
请澄清您所说的无法下载您的错误信息是什么
-
指定您遇到的错误
-
@DaImTo 我得到“下载失败”作为输出
-
这就是您输出的消息,您将不得不从谷歌获得响应,并向我们表明我们无法在不知道下载失败原因的情况下对其进行调试。
-
@NitinSawant 我得到“下载失败”作为输出,我不知道它的原因。
标签: c# google-api google-drive-api google-api-dotnet-client