Sharepoint C# 如何通过图片库的标题检索所有图片及其名称

Sharepoint C# How to retrieve all pictures and their name by Title of Picture library

谁知道如何用SP C#通过图片库(List)的标题获取图片。可以指导我。

希望了解SharePoint的各位能帮到我。

非常感谢。

您可以使用 CSOM 来实现,演示代码在这里:https://www.codesharepoint.com/csom/get-all-items-in-sharepoint-using-csom

using Microsoft.SharePoint.Client;
 
using (ClientContext clientContext = new ClientContext("http://MyServer/sites/MySiteCollection"))
{
// clientcontext.Web.Lists.GetById - This option also can be used to get the list using List GUID
// This value is NOT List internal name
List targetList = clientContext.Web.Lists.GetByTitle("List Name");
 
// Optioanlly you can use overloaded method CreateAllItemsQuery(int rowlimits, params viewfields): where using "rowlimits" you can limit the number of rows returned and viewfields will return only specified fields in the result set
// This method will get all the items from all the folders and sub folders including folders and sub folders too
CamlQuery oQuery = CamlQuery.CreateAllItemsQuery();
 
ListItemCollection oCollection = targetList.GetItems(oQuery);
clientContext.Load(oCollection);
clientContext.ExecuteQuery();
 
foreach (ListItem oItem in oCollection)
{
Console.WriteLine(oItem["Title"].ToString());
}
}