4

I am downloading a file from a remote server. The file is more than 2GB in size. I am requesting the file by calling

await _client.SendAsync(message, HttpCompletionOption.ResponseHeadersRead);

However, the call is throwing the above exception.

How can I download a file > 2GB?

4
  • You had this problem on full .NET Framework or Core? Commented Nov 25, 2020 at 14:07
  • 1
    The person having closed this didn't understand that Nikki Locke didn't ask for the header but for the whole response content Commented Aug 4, 2023 at 10:07
  • 1
    Can you provide a minimal set of steps to reproduce the issue you're describing? Commented Oct 15 at 22:46
  • You need to just make the request and then grab the response stream to read from. The code given does not provide any useful information about what you are actually trying to do to retrieve the response. You need to call ReadAsStream() on the response and then read from that stream until you can't read anymore, or use CopyToAsync and pass it a destination stream. Then things are completed. From the exception given, it is not possible to know what you are actually doing wrong other than trying to read the whole thing at once, which isn't going to work for huge responses. Commented Oct 20 at 7:14

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.