Otto Rahn
Otto Rahn

Reputation: 173

Download the file from Google.Drive via WebClient C#

Me need to download the file at: https://drive.google.com/u/0/uc?id=1sSR9kWifwjIP5qFWcyxGCxN0-MoEd_oo&export=download

But after downloading the file, I get just a document with a single line: "Google Drive-Virus scan warning". In theory, I should download the file from the link specified in the url (I got it through the browser console), but instead I download an incomprehensible document with one line. As far as I understand, I download the page markup, but not the file itself. How can this be fixed ?

To download a file, use the following method:

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();
        }
    }

Upvotes: 2

Views: 12029

Answers (1)

Jeremy Thompson
Jeremy Thompson

Reputation: 65692

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

Create Credentials:

enter image description here

An API key will be generated, copy the key and paste it somewhere as we will need it later.

enter image description here

Step 2. Tweak Shared URL

Look for the Google Drive file that you wish to download directly without any virus warning. Here copy the File ID and paste it somewhere safe

enter image description here

Open Chrome and Enter the following Google APIs URL.

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

Enter the file id copied in the fileID section and the API Key in the APIKey section.

enter image description here

Hit Enter and the file will start downloading without any warning symbol.

enter image description here

Upvotes: 2

Related Questions