클라이언트 컨텍스트를 사용하여 원격으로 스타일 라이브러리에 업로드 할 수 있습니까?

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/71374

  •  10-12-2019
  •  | 
  •  

문제

제목이 말한 것으로

.클라이언트 컨텍스트를 사용하여 원격 SharePoint 인스턴스에 연결하는 Win Forms 앱이 있습니다.지금은 프로그래밍 방식으로 파일을이 스타일 라이브러리에 업로드하고 어떤 사용 권한을 고려해야합니까?

도움이 되었습니까?

해결책

이 라이브러리에 대한 기여 권한이 있어야하며 클라이언트 객체 모델을 사용해야합니다.

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";              

      list.RootFolder.Files.Add(fileCreationInformation);

      clientContext.Load(list);
      clientContext.ExecuteQuery();        
}
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top