title: How to use MultipartFormDataContent in a HttpWebRequest?
body: <p>I'm currently trying to submit a form containing several files to its destination server but do not know how to send this form data off using HttpWebRequest. The form is of type MultipartFormDataContent. I have so far seen ways to submit a form using HttpWebRequest but this is done by constructing the form as a string and then converting it into a byte array. So something like this,</p>
  
  <pre><code>string postData = "";
  
          foreach (string key in postParameters.Keys)
          {
              postData += HttpUtility.UrlEncode(key) + "="
                    + HttpUtility.UrlEncode(postParameters[key]) + "&amp;";
          }
  
          HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
          myHttpWebRequest.Method = "POST";
  
          byte[] data = Encoding.ASCII.GetBytes(postData);
  Stream requestStream = myHttpWebRequest.GetRequestStream();
          requestStream.Write(data, 0, data.Length);
          requestStream.Close();
  </code></pre>
  
  <p>However, my form is not a string but of type MultipartFormDataContent and so I'm not sure what to do.</p>