gpt4 book ai didi

sharepoint - 从上传的文件获取 Id 到 Sharepoint 2013 DocumentLibrary

转载 作者:行者123 更新时间:2023-12-03 17:52:16 25 4
gpt4 key购买 nike

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

最佳答案

File.ListItemAllFields property获取一个值,该值指定与文件对应的列表项的列表项字段值。

例子:

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

关于sharepoint - 从上传的文件获取 Id 到 Sharepoint 2013 DocumentLibrary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22201720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com