Here's an example code snippet which reads an entire file and posts its contents to a web server using HttpClient in C#:
main.cs871 chars35 linesThe above code uses HttpClient to send an HTTP POST request to the specified URI with the contents of the specified file as the request body. The StreamContent class is used to wrap the file stream so that the request body can be read from it. The PostAsync method sends the HTTP POST request and returns a HttpResponseMessage which contains the response from the web server. The IsSuccessStatusCode property of the HttpResponseMessage is used to check whether the response was successful.
gistlibby LogSnag