title: how to download file form Google Drive asp.net
body: <p>I am trying to download files from google drive below is my code</p>
  
  <pre><code>private static IAuthenticator CreateAuthenticator()
  {
      var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
      provider.ClientIdentifier = ClientCredentials.CLIENT_ID;
      provider.ClientSecret = ClientCredentials.CLIENT_SECRET;
      return new OAuth2Authenticator&lt;NativeApplicationClient&gt;(provider, GetAuthorization);
  }
  
  
  public static System.IO.Stream DownloadFile(
          IAuthenticator authenticator, Google.Apis.Drive.v2.Data.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;
          }
      }
  </code></pre>
  
  <p>in .aspx page code
           {
           System.IO.Stream stream = Utilities.DownloadFile(CreateAuthenticator(), FIle);</p>
  
  <pre><code>            //Convert the stream to an array of bytes.
              System.IO.BinaryReader br = new System.IO.BinaryReader(stream);
              Byte[] byteArray = br.ReadBytes((int)stream.Length);
  </code></pre>
  
  <p>its showing This stream does not support seek operations.</p>
  
  <p>where is error 
  thank u....</p>