因此,我正在尝试创建一种方法,该方法本质上用于更改 SharePoint 中字段的值。
这是我目前所拥有的......
static String fieldName1 = "Title";
static String fieldName2 = "Keywords";
static String title = "A Beautiful Sunset";
static String keywords1 = "test1";
static String keywords2 = "test2";
static String keywords3 = "test3";
static NetworkCredential credentials = new NetworkCredential(username, password, domain);
static ClientContext clientContext = new ClientContext(URL);
static Web site = clientContext.Web;
static List list = site.Lists.GetByTitle(listName);
static FileCreationInformation newFile = new FileCreationInformation();
private static void updateFields()
{
clientContext.Load(list);
FieldCollection fields = list.Fields;
clientContext.Load(fields);
clientContext.Load(list.RootFolder);
ListItemCollection listItems = list.GetItems(CamlQuery.CreateAllItemsQuery());
clientContext.Load(listItems);
clientContext.ExecuteQuery();
foreach (var listItem in listItems)
{
Console.WriteLine("Id: {0} Title: {1}", listItem.Id, listItem["Title"]);
clientContext.Load(listItem.File);
clientContext.ExecuteQuery();
Console.WriteLine("listItem File Name: {0}", listItem.File.Name);
if (listItem.File.Name.Contains("Sunset"))
{
////????????
}
listItem.Update();
}
clientContext.ExectueQuery();
}
我知道如何到达该字段,但我不确定如何访问该字段中的实际值并对其进行修改。有没有人有任何使用客户端对象模型的经验?感谢您提供的任何帮助!