【发布时间】:2020-06-26 08:57:11
【问题描述】:
我目前正在创建可以将文件上传到 SharePoint 自定义列表的应用程序,这可能吗?如果是这样,有人可以分享我可以使用和学习的链接吗?
注意:我想将文件上传到自定义列表而不是文档库
【问题讨论】:
标签: c# asp.net-mvc sharepoint sharepoint-online
我目前正在创建可以将文件上传到 SharePoint 自定义列表的应用程序,这可能吗?如果是这样,有人可以分享我可以使用和学习的链接吗?
注意:我想将文件上传到自定义列表而不是文档库
【问题讨论】:
标签: c# asp.net-mvc sharepoint sharepoint-online
文件可以作为列表项的附件托管。
List list = context.Web.Lists.GetByTitle("Listtitle");
ListItem item = list.GetItemById(itemid);
var attachment = new AttachmentCreationInformation();
string filePath = @"C:\Lee\template.xlsx";
attachment.FileName = Path.GetFileName(filePath);
attachment.ContentStream = new MemoryStream(System.IO.File.ReadAllBytes(filePath));
Attachment att = item.AttachmentFiles.Add(attachment);
context.Load(att);
context.ExecuteQuery();
【讨论】: