using Microsoft.SharePoint.Client;
public static void Main()
UploadDocument("http://tenant.sharepoint.com/sites/Files/", "FTP", "FTP", "Document Title", );
public void UploadDocument(string siteURL, string documentListName, string documentListURL, string documentName, byte[] documentStream)
using (ClientContext clientContext = new ClientContext(siteURL))
List documentsList = clientContext.Web.Lists.GetByTitle(documentListName);
var fileCreationInformation = new FileCreationInformation();
fileCreationInformation.Content = documentStream;
fileCreationInformation.Overwrite = true;
fileCreationInformation.Url = siteURL + documentListURL + documentName;
Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(
fileCreationInformation);
uploadFile.ListItemAllFields.Update();
clientContext.ExecuteQuery();