Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
3.33/5 (2 votes)
i have developed a software that is configured with almost all google apps but have no idea how to deal with Google Drive (download file from Google Drive)? Can somebody provide a code snipet or any clue where to go as i cannot find a good article on google.

Thanks in advance
Posted

Please check below link for more info.

Note: For c# just click .Net tab

Download Files from Google Drive
 
Share this answer
 
Comments
agent_kruger 16-Feb-14 2:45am    
thank you sir, but can i ask you for a favour can you also provide the URL of the DLL's.
Sampath Lokuge 16-Feb-14 3:33am    
Here is the link : https://developers.google.com/api-client-library/dotnet/get_started
XML
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;
    }
  }
}
 
Share this answer
 
Comments
Ainy Mughal 27-Feb-14 1:52am    
where?
agent_kruger 27-Feb-14 2:21am    
sir , can you provide the direct link of the GoogleDrive libraries?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900