Could you help me add the file to the Sharepoint document library? I found some articles in .NET, but I did not get a complete concept on how to do this.
I uploaded the file without metadata using this code:
if (fuDocument.PostedFile != null) { if (fuDocument.PostedFile.ContentLength > 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); } } } }
This code works fine as it is, but I need to upload a metadata file. Please help me by editing this code if possible. I created 3 columns in my document library.
source share