【问题标题】:Is it possible to upload files to a custom list in SharePoint online using c#是否可以使用 c# 将文件上传到 SharePoint Online 中的自定义列表
【发布时间】:2020-06-26 08:57:11
【问题描述】:

我目前正在创建可以将文件上传到 SharePoint 自定义列表的应用程序,这可能吗?如果是这样,有人可以分享我可以使用和学习的链接吗?

注意:我想将文件上传到自定义列表而不是文档库

【问题讨论】:

    标签: c# asp.net-mvc sharepoint sharepoint-online


    【解决方案1】:

    文件可以作为列表项的附件托管。

    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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-28
      • 1970-01-01
      • 2013-08-18
      • 1970-01-01
      • 2021-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多