title: C# HTTP Request
body: <p>Hello I got a Problem sending a HTTP Request in C#
  I´d like to upload a File in a HTTP Request but I´m not sure how to do it</p>
  
  <p>Here is the html Code:</p>
  
  <pre><code>&lt;form action="/decrypt/upload" method="post" enctype="multipart/form-data"&gt;
              &lt;fieldset&gt;
                  &lt;p class="formrow file_upload"&gt;
                  &lt;label for="dlcfile"&gt;Container File&lt;/label&gt;
                  &lt;input type="file" class="file_field" name="dlcfile" id="dlcfile"/&gt;
                  &lt;input type="text" value="Click here to select a file..." class="file_overlay" /&gt;
                  &lt;/p&gt;
                  &lt;p class="buttonrow"&gt;&lt;button type="submit"&gt;Submit »&lt;/button&gt;&lt;/p&gt;
              &lt;/fieldset&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>And here is my C# Code:</p>
  
  <pre><code>public static void decryptContainer(string path)
      {
          HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://dcrypt.it/decrypt/upload");
          request.Method = "POST";
          request.ContentType = "application/x-www-form-urlencoded";
  
  
          using (StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII))
          {
              writer.Write("dlcfile=" + path);
          }
  
          HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  
          using (StreamReader reader = new StreamReader(response.GetResponseStream()))
          {
              Console.WriteLine(reader.ReadToEnd());
          }
      }
  </code></pre>
  
  <p>I know that I have to give the parameter an File, but I just don´t know how to handel that in C#, could someone plx help me :)</p>