2

ファイルをSharepoint 2013ドキュメントライブラリにアップロードするこの機能があります。ドキュメント ライブラリ エントリの新しく作成された ID を取得できるようにしたいと考えています。

 public void UploadFileToSharePoint(string file)
    {
        ClientContext context = new ClientContext("http://test-sp01");
        Web web = context.Web;

        FileCreationInformation newFile = new FileCreationInformation();
        newFile.Content = System.IO.File.ReadAllBytes(file);
        newFile.Url = System.IO.Path.GetFileName(file);

        List docs = web.Lists.GetByTitle("TestDocumentLibrary");
        Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);

        context.Load(uploadFile);

        context.ExecuteQuery();
    }
4

1 に答える 1