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?
ReadAsStream()on the response and then read from that stream until you can't read anymore, or useCopyToAsyncand 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.