Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. string file = @"Path Of the file";
  2. System.IO.FileStream fs = new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.Read);
  3. using (var ctx = new AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, "CLIENTID","CLIENTSECRET"))
  4. {
  5. try
  6. {
  7. ctx.Load(ctx.Web, p => p.Title);
  8. ctx.ExecuteQuery();
  9. Console.WriteLine(ctx.Web.Title);
  10. Microsoft.SharePoint.Client.File.SaveBinaryDirect(ctx, "RelativePathToDocumentLibrary" + "/test.docx", fs, false);
  11. }
  12. catch (Exception ex)
  13. {
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement