クライアントコンテキストを使用してスタイルライブラリにリモートでアップロードすることが可能ですか?

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

  •  10-12-2019
  •  | 
  •  

質問

タイトルとして言うように。クライアントコンテキストを使用してリモートSharePointインスタンスに接続するWinフォームアプリがあります。プログラム的には、このスタイルライブラリにファイルをアップロードし、どの権限を考慮に入れなければならないか?

役に立ちましたか?

解決

このライブラリの貢献権限を持ち、クライアントオブジェクトモデルを使用する必要があります。

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