I'm just doing some tests for upload files with C# console App but I can't. I've tried everything but with no success, here my code. ¿What do I try? In the List "Contact" there is a sub-folder called "demo" I try to upload the file there in the "demo" folder
using (SP.ClientContext cnx = new SP.ClientContext("https://test.sharepoint.com/sites/test01"))
{
string password = "123";
string account = "[email protected]";
var secret = new SecureString();
foreach (char c in password)
{
secret.AppendChar(c);
}
cnx.Credentials = new SP.SharePointOnlineCredentials(account, secret);
SP.Web web = cnx.Web;
SP.FileCreationInformation newFile = new SP.FileCreationInformation();
newFile.Content = System.IO.File.ReadAllBytes("document.pdf");
newFile.Url = @"demo/document.pdf";
SP.List docs = web.Lists.GetByTitle("Contact");
SP.File uploadFile = docs.RootFolder.Files.Add(newFile);
cnx.Load(docs);
cnx.Load(uploadFile);
cnx.ExecuteQuery();
Console.WriteLine("done");
};
what it throws me is the exception Microsoft.SharePoint.Client.ServerException: 'File not found'
I really appreciate your help.