title: File upload to web server using C#
body: <p>I am trying to upload file in web server as following using C#</p>
  
  <pre><code>try
  {
      // create WebClient object
      WebClient client = new WebClient();
  
      string myFile = @"D:\test_file.txt";
      client.Credentials = CredentialCache.DefaultCredentials;
  
      // client.UploadFile(@"http://mywebserver/myFile", "PUT", myFile);
      client.UploadFile(@"http://localhost/uploads", "PUT", myFile);
      client.Dispose();
  }
  catch (Exception err)
  {
      MessageBox.Show(err.Message);
  }
  </code></pre>
  
  <p>But every time I am getting this error:</p>
  
  <blockquote>
    <p>The remote server returned an error: (405) Method Not Allowed.</p>
  </blockquote>