Method ExtInternet.Save
Overload
Saves content in a file. Downloads if need.
public static HttpResponseMessage Save(this HttpResponseMessage t, string file)
Parameters
t (HttpResponseMessage) |
file (string)
File path. The function uses pathname.normalize. Creates parent directory if need. |
Returns
HttpResponseMessage
This. |
Exceptions
HttpRequestException
Failed HTTP request. |
ArgumentException
Not full path. |
Exception
Exceptions of System.Net.Http.HttpContent.ReadAsStream, System.IO.File.Create and other used functions. |
Remarks
By default HttpClient and similar functions download content to a memory buffer before returning. To avoid it, use completionOptionSystem.Net.Http.HttpCompletionOption.ResponseHeadersRead, or ExtInternet.Get with dontWaittrue
. Then call this function (it will download the file), and finally dispose the HttpResponseMessage.