title: How to send a file and form data with HttpClient in C#
body: <p>How can I send a file and form data with the <code>HttpClient</code>?</p>
  
  <p>I have two ways to send a file or form data. But I want to send both like an HTML form. How can I do that? Thanks. </p>
  
  <p>This is my code: </p>
  
  <pre><code>if (openFileDialog1.ShowDialog() == DialogResult.OK)
  {
      var client = new HttpClient();
      var requestContent = new MultipartFormDataContent();
      filename = openFileDialog1.FileName;
      array = File.ReadAllBytes(filename);
      var imageContent = new ByteArrayContent(array);
      imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse("audio/*");
      requestContent.Add(imageContent, "audio", "audio.wav");
      var values = new Dictionary&lt;string, string&gt;
      {
          { "token", "b53b99534a137a71513548091271c44c" },
      };
      var content = new FormUrlEncodedContent(values);
      requestContent.Add(content);
      var response = await client.PostAsync("localhost", requestContent);
      var responseString = await response.Content.ReadAsStringAsync();
      txtbox.Text = responseString.ToString();
  }
  </code></pre>