【发布时间】:2017-06-30 15:08:23
【问题描述】:
我正在尝试获取 Sharepoint 在线列表项或其网址的附件。到目前为止,我只找到了解决方案 like these。
但问题是,当我浏览附件所在的文件夹时,它是空的。
这很令人困惑,因为在 SharepointClientBrowser 中,文件夹不为空。如果不在带有 url https://scundp.sharepoint.com/sites/list_overview_test/f0/Lists/Testlist2/Attachments/2 的文件夹中,还应该将 https://scundp.sharepoint.com/sites/list_overview_test/f0/Lists/Testlist2/Attachments/2/Dokument1.png 存储在哪里?
在我的代码中,我试图将 listItem 的附件 Urls 写入newListItem["AFiles"]. listItem["Attachments"].ToString() == "True" 工作正常,因此只有在有任何附件时才会运行块。
但是 bool h 设置为 false 并且文件夹也被解释为空。
我正在开发的 Sharepoint 插件具有权限:Web - 管理、网站集 - fullControl。整个网站集的设置“在客户端应用程序中打开文档”处于活动状态。
if (listItem["Attachments"].ToString() == "True")
{
bool h = listItem.AttachmentFiles.AreItemsAvailable;
try
{
Web oWeb = context.Web;
Folder folder = oWeb.GetFolderByServerRelativeUrl(siteName + "/Lists/" + listName + "/Attachments/" + listItem["ID"]);
context.Load(folder);
context.ExecuteQuery();
FileCollection attachments = folder.Files;
context.Load(attachments);
context.ExecuteQuery();
newListItem["AFiles"] = "";
foreach (Microsoft.SharePoint.Client.File oFile in folder.Files)
{
newListItem["AFiles"] = newListItem["AFiles"] + " " + oFile.ServerRelativeUrl;
}
}
catch (ServerException ex)
{
}
}
}
【问题讨论】:
标签: c# sharepoint