Вы установили учетные данные для своего запроса?
Демо для загрузки.
using (ClientContext context = new ClientContext("https://xxx.sharepoint.com/sites/site"))
{
string s = "password";
SecureString passWord = new SecureString();
foreach (var c in s)
passWord.AppendChar(c);
context.Credentials = new SharePointOnlineCredentials("user@xxx.onmicrosoft.com", passWord);
//List docs = context.Web.Lists.GetByTitle("largeLib1");
Folder folder = context.Web.GetFolderByServerRelativeUrl("/sites/site/largeLib1/set2");
var filePath = @"C:\Lee\template.xlsx";
using (FileStream fs = new FileStream(filePath, FileMode.Open))
{
FileCreationInformation flciNewFile = new FileCreationInformation();
flciNewFile.ContentStream = fs;
flciNewFile.Url = System.IO.Path.GetFileName(filePath);
flciNewFile.Overwrite = true;
Microsoft.SharePoint.Client.File uploadFile = folder.Files.Add(flciNewFile);
context.Load(uploadFile);
context.ExecuteQuery();
}
}
загрузить демо