Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
正在从上载到Sharepoint 2013 DocumentLibrary的文件获取Id_Sharepoint_Csom - Fatal编程技术网

正在从上载到Sharepoint 2013 DocumentLibrary的文件获取Id

正在从上载到Sharepoint 2013 DocumentLibrary的文件获取Id,sharepoint,csom,Sharepoint,Csom,我有此功能,可以将文件上载到Sharepoint 2013文档库中。我希望能够检索新创建的文档库条目Id public void UploadFileToSharePoint(string file) { ClientContext context = new ClientContext("http://test-sp01"); Web web = context.Web; FileCreationInformation newFile

我有此功能,可以将文件上载到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();
    }
获取一个值,该值指定与文件对应的列表项的列表项字段值

例如:

context.Load(uploadFile,f => f.ListItemAllFields) ;
context.ExecuteQuery();
//Print List Item Id
Console.WriteLine("List Item Id: {0}", uploadFile.ListItemAllFields.Id);