【问题标题】:Download the file from Google.Drive via WebClient C#通过 WebClient C# 从 Google.Drive 下载文件
【发布时间】:2021-07-23 00:30:38
【问题描述】:

我需要下载文件到:https://drive.google.com/u/0/uc?id=1sSR9kWifwjIP5qFWcyxGCxN0-MoEd_oo&export=download

但下载文件后,我只得到一个文件,其中只有一行:“Google Drive-Virus scan warning”。理论上,我应该从 url 中指定的链接下载文件(我是通过浏览器控制台获取的),但我下载的是一行难以理解的文档。据我了解,我下载的是页面标记,而不是文件本身。如何解决这个问题?

要下载文件,请使用以下方法:

using System;
using System.Net;


public class Program
{

    public static void Main(string[] args)
    {
        {
            string url = "https://drive.google.com/u/0/uc?export=download&confirm=pKfr&id=1sSR9kWifwjIP5qFWcyxGCxN0-MoEd_oo";
            string savePath = @"C:\Users\Saint\Desktop\TaskRetail\yml.xml";
            WebClient client = new WebClient();
            client.DownloadFile(url, savePath);
            Console.ReadLine();
        }
    }

【问题讨论】:

    标签: c# .net google-chrome


    【解决方案1】:

    参考:https://bytesbin.com/skip-google-drive-virus-scan-warning-large-files/

    创建凭据:

    将生成一个 API 密钥,复制该密钥并将其粘贴到我们稍后需要的地方。

    步骤 2. 调整共享 URL

    查找您希望直接下载且没有任何病毒警告的 Google 云端硬盘文件。 在此处复制文件 ID 并将其粘贴到安全的地方

    打开 Chrome 并输入以下 Google API URL。

    https://www.googleapis.com/drive/v3/files/FileID?alt=media&key=APIKey

    在fileID部分输入复制的文件id,在APIKey部分输入API Key。

    按 Enter,文件将开始下载,没有任何警告符号。

    【讨论】:

      猜你喜欢
      • 2015-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 2012-01-14
      相关资源
      最近更新 更多