小编Meh*_*ğlu的帖子

从上传的文件中获取 ID 到 Sharepoint 2013 DocumentLibrary

我有这个功能,可以将文件上传到 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();
    }
Run Code Online (Sandbox Code Playgroud)

sharepoint csom

2
推荐指数
1
解决办法
6873
查看次数

标签 统计

csom ×1

sharepoint ×1