title: Uploading file with metadata
body: <p>Could you help me for how to add a file to the Sharepoint document library? I found some articles in .NET, but I didn't get the complete concept of how to accomplish this. </p>
  
  <p>I uploaded a file without metadata by using this code:</p>
  
  <pre><code>if (fuDocument.PostedFile != null)
                  {
                      if (fuDocument.PostedFile.ContentLength &gt; 0)
                      {
                          Stream fileStream = fuDocument.PostedFile.InputStream;
                          byte[] byt = new byte[Convert.ToInt32(fuDocument.PostedFile.ContentLength)];
                          fileStream.Read(byt, 0, Convert.ToInt32(fuDocument.PostedFile.ContentLength));
                          fileStream.Close();
  
  
                          using (SPSite site = new SPSite(SPContext.Current.Site.Url))
                          {
                              using (SPWeb webcollection = site.OpenWeb())
                              {
                                  SPFolder myfolder = webcollection.Folders["My Library"];
                                  webcollection.AllowUnsafeUpdates = true;
                                  myfolder.Files.Add(System.IO.Path.GetFileName(fuDocument.PostedFile.FileName), byt);
  
                              }
                          }
                      }
                  }
  </code></pre>
  
  <p>This code is working fine as is, but I need to upload a file with metadata. Please help me by editing this code if it is possible. I created 3 columns in my document library.</p>