3
Answers

Upload and download files in Google Drive C#.NET

Photo of Samuel Prabhu

Samuel Prabhu

7y
1.8k
1
We have developed a desktop application in Visual Studio 2008.
Now we are looking to upload the files (updation) in google drive.
So that clients can download the updation from google drive.
I have searched lot of articles, Everything suggesting nudget packing which requires VS2013 above. So is there any alternate solution to achieve my task with using VS2008 itself.
Kindly suggest 

Answers (3)

1
Photo of Amit Gupta
NA 16.5k 25.7k 7y
You can go to the official google api for accessing and doing all the stuffs with google drive.
 
Look at the below link that will guide you to get started with it.
https://developers.google.com/drive/v2/web/quickstart/dotnet
 
I believe that v2 should work with your existing IDE but v3 have more functionality and upgrades features.
 
Moreover, to have more command over this, you should upgrade your IDE, as it was quite old now a days.
 
Good Luck !! 
 
0
Photo of Khaja Moizuddin
NA 6.3k 206.6k 7y
http://www.daimto.com/google-drive-api-c-download/ https://www.codeproject.com/Questions/728116/How-to-download-a-file-from-Google-Drive-in-csharp https://stackoverflow.com/questions/35056500/download-file-from-google-drive-using-c-sharp-without-google-api https://forums.asp.net/t/2096352.aspx?Upload+Files+to+Google+Drive+by+ASP+Net+C+
0
Photo of Sundar
NA 9.6k 94.6k 7y
1) http://www.daimto.com/google-drive-api-c-download/
 
2)
 
using Google.Apis.Authentication;
using Google.Apis.Drive.v2;
using Google.Apis.Drive.v2.Data;
using System.Net;
public class MyClass {
// ...
/// <summary>
/// Download a file and return a string with its content.
/// </summary>
/// <param name="authenticator">
/// Authenticator responsible for creating authorized web requests.
/// </param>
/// <param name="file">Drive File instance.</param>
/// <returns>File's content if successful, null otherwise.</returns>
public static System.IO.Stream DownloadFile(
IAuthenticator authenticator, File file) {
if (!String.IsNullOrEmpty(file.DownloadUrl)) {
try {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
new Uri(file.DownloadUrl));
authenticator.ApplyAuthenticationToRequest(request);
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK) {
return response.GetResponseStream();
} else {
Console.WriteLine(
"An error occurred: " + response.StatusDescription);
return null;
}
} catch (Exception e) {
Console.WriteLine("An error occurred: " + e.Message);
return null;
}
} else {
// The file doesn't have any content stored on Drive.
return null;
}
}
}
 
Hope this will help. Thanks in advance