title: How to upload a file to a document library in sharepoint?
body: <p>I have a byte[] data and I want to upload it to sharepoint site using c#. I also want to pass credentials for it. Can anyone please guide me.</p>
  
  <p>The code I tried is:</p>
  
  <pre><code>        Uri destUri = new Uri("http://test.net/excel/docs/Forms/AllItems.aspx/");
          WebRequest req = WebRequest.Create(destUri);
          req.Method = "PUT";
          req.Credentials = CredentialCache.DefaultCredentials;
          using (req.GetRequestStream())
          {
              string destFilename = @"\\test.net\excel\docs\501.xls";
              byte[] data = new byte[10];
              System.IO.File.WriteAllBytes(destFilename, data);
          }
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>Access Denied
  </code></pre>