As title says. I have a win forms app that connects to a remote SharePoint instance using the client context. How can I now, programmatically, upload a file to this style library and what permissions must I take into account?


You need to have contribute permission for this library, and use client object model.

using (ClientContext clientContext = new ClientContext("http://yoursitecollection"))
      Web web = clientContext.Web;
      List list = web.Lists.GetByTitle("Style library");               

      FileCreationInformation fileCreationInformation = new FileCreationInformation();                  

      byte[] file = System.IO.File.ReadAllBytes(@"C:\TestFile.txt");
      fileCreationInformation.Content = file;
      fileCreationInformation.Url = @"http://yoursitecollection/Style library/TestFile.txt";              


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.