Shebin Shebin - 9 months ago 179
ASP.NET (C#) Question

Download file from google drive using c# without google API

As per the requirement ,the client is provide with an exe-(which contains the url of file to be downloaded) If we use the google api, we need to provide additional references along with the exe. It is not allowed by the client.

I used the webclient to download the file, but its downloading the file with doc type as HTML. My requirement is to download the file form google drive without using google API. Is there any way to do that?

I have tried the code as below

WebClient wb = new WebClient();
wb.DownloadFile("", @"C:\TFS\test\test.pdf");

Result as shown below

enter image description here

Answer Source

This should help you.

Below is the standard sharing url for google drive.

the format you need to use for direct downloads is:

this will link directly to the file instead of to the drive view in your current example.

so, for example, if your sharing url is

then your direct download url is

Note, this is only for files you have uploaded yourself that were not created in drive itself (ie, doc, presentation, spreadsheet) using the google docs. to do that the format changes (will update answer if you need it)