title: Handling HttpPostedFile in C#
body: <p>I have a C#.net web application that can send (by POST method) files to another application. In the second application I have the below code to retrieve the posted file.</p>
  
  <pre><code>HttpPostedFile hpf = Request.Files[0];
  </code></pre>
  
  <p>Now I can save the file by the code</p>
  
  <pre><code>hpf.SaveAs("The path to be saved");
  </code></pre>
  
  <p>But <em>I need to send it again to another application without saving it here</em> (without saving in 2nd appln I need to send it to a third appln).</p>
  
  <p>(Now I can do is that save the file in second application and from there post it to the third application by giving the path exactly same as what I did in my 1st application. But I need another solution.)</p>
  
  <p>I tried hpf.fileName but its giving only the filename (eg:test.txt). When I tried like below</p>
  
  <pre><code>string file = hpf.FileName;
  string url = "the url to send file";
      using (var client = new WebClient())
      {
          byte[] result = client.UploadFile(url, file);
          string responseAsString = Encoding.Default.GetString(result);
      }
  </code></pre>
  
  <p>A WebException occured like 'An exception occurred during a WebClient request.'</p>
  
  <p>Is there any method to do it in C# .net?</p>