public void UploadDocument(string siteURL, string documentListName,string documentListURL, string documentName,byte[] documentStream) { try { using (ClientContext clientContext = new ClientContext(siteURL)) { //Get Document List Microsoft.SharePoint.Client.List documentsList = clientContext.Web.Lists.GetByTitle(documentListName); var fileCreationInformation = new FileCreationInformation(); //Assign to content byte[] i.e. documentStream fileCreationInformation.Content = documentStream; //Allow owerwrite of document fileCreationInformation.Overwrite = true; //Upload URL System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("i:0#.f|sqlmembers|admin", "admin@!23", "CS-avr-01"); ClientContext context = ClaimClientContext.GetAuthenticatedContext(siteURL); fileCreationInformation.Url =documentListName + "//" + documentListURL; Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add( fileCreationInformation); //Update the metadata for a field having name "DocType" uploadFile.ListItemAllFields["DocType"] = "Favourites"; uploadFile.ListItemAllFields.Update(); clientContext.ExecuteQuery(); } } catch (Exception ex) { } finally { } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)