0

I want to download my files from Dropbox using dropbox.api.

My current code is

public static void download(ListBox file)
    {
        file.Items.Clear();
        using (var dbx = new DropboxClient("mytoken"))
        {
            using (var responses = dbx.Files.DownloadAsync("/pakistan.txt"))      
            {

          HttpContext.Current.Response.Clear();

          HttpContext.Current.Response.ClearHeaders();

          HttpContext.Current.Response.ClearContent();

          HttpContext.Current.Response.AddHeader("Content-Disposition", attachment; filename=" + responses.Result.Response.Name);

          HttpContext.Current.Response.AddHeader("Content-Length", responses.Result.Response.Size.ToString());

          HttpContext.Current.Response.ContentType = "text/plain";

          HttpContext.Current.Response.Flush();

          HttpContext.Current.Response.TransmitFile(responses.Result.Response.Name);

          HttpContext.Current.Response.End();
            }
        }
    }

It's downloading the file, but contents are not completely present in the file.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
Ali Ather
  • 1
  • 3
  • 2
    Please refer to [ask], in particular you should explain more what you want to do, what you've tried, how far you got, etc. If you "get" (as in *understand*?) how to download file on the client side, then it would seem you already have what you need, wouldn't it? – Lasse V. Karlsen May 09 '16 at 12:39
  • did u tried searching for this on google ?? I am not sure what ur actual code look likes, you can try from [here](https://dzone.com/articles/how-download-file-dropbox) may be it may give you some clue on how to proceed. – Nad May 09 '16 at 12:39
  • There are a number of DropBox API for C# to be found at https://www.dropbox.com/developers-v1/core/sdks/other. Select one and follow the tutorials. – derpirscher May 09 '16 at 12:49
  • Possible duplicate of [Download file from Dropbox with JavaScript](http://stackoverflow.com/questions/15791947/download-file-from-dropbox-with-javascript) – Lajos Arpad May 09 '16 at 12:50
  • Are you trying to use your code as a proxy between the client and Dropbox or are you looking to save the file from Dropbox to your server? – Gavin May 10 '16 at 15:11
  • @derpirscher if you didn't notice he's using the dropbox api. Ali, I would suggest using a synchronous method. Also it appears you get the file and send it somewhere else? – Richard Barker May 10 '16 at 15:13
  • @richardbarker if you didn't notice, I posted my comment yesterday. the source was only inserted today. – derpirscher May 10 '16 at 17:30

0 Answers0