Created
March 1, 2021 12:43
-
-
Save lfgrando/812c147c4190f714579d92456231e462 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
private static readonly HttpClient _httpClient = new HttpClient(); | |
static void Main(string[] args) | |
{ | |
var url = ""; | |
byte[] fileBytes = null; | |
var httpMessage = new HttpRequestMessage(HttpMethod.Get, url); | |
var response = _httpClient.SendAsync(httpMessage).GetAwaiter().GetResult(); | |
using (var stream = response.Content.ReadAsStreamAsync().GetAwaiter().GetResult()) | |
using (var memStream = new MemoryStream()) | |
{ | |
stream.CopyTo(memStream); | |
fileBytes = memStream.ToArray(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment