title: C# Downloading a spreadsheet from Google Drive
body: <p>I'm trying to download a sheet from Google Drive using the ExportLinks from FileResource API.</p>
  
  <p>However, the response I'm getting is not a spreadsheet but an HTML file representing the spreadsheet or something like that.</p>
  
  <p>Here is the request I'm using:</p>
  
  <pre><code>            FilesResource.GetRequest getF = new FilesResource.GetRequest(service, "1y92Rok6oYKMwvc-Oq4Uurah7y552sfmIbyD9Wzmpq54");
              Google.Apis.Drive.v2.Data.File f = getF.Execute();
              string downloadUrl = f.ExportLinks["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];
              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(downloadUrl));
              HttpWebResponse response = (HttpWebResponse)request.GetResponse();
              ReadWriteStream(response.GetResponseStream(), File.OpenWrite("D:\\tmp.xlsx"));
  </code></pre>
  
  <p>The function I'm using to store the stream:</p>
  
  <pre><code>static private void ReadWriteStream(Stream readStream, Stream writeStream)
          {
              int Length = 256;
              Byte[] buffer = new Byte[Length];
              int bytesRead = readStream.Read(buffer, 0, Length);
              // write the required bytes
              while (bytesRead &gt; 0)
              {
                  writeStream.Write(buffer, 0, bytesRead);
                  bytesRead = readStream.Read(buffer, 0, Length);
              }
              readStream.Close();
              writeStream.Close();
          }
  </code></pre>
  
  <p>Can anyone point out what I'm doing wrong?</p>