是否可以使用Sharepoint Client ObjectModel更新Created / Modified字段而无需更新版本?
var file = _ClientContext.Web.GetFileByServerRelativeUrl(serverRelativeUrl);
_ClientContext.Load(file);
_ClientContext.ExecuteQuery();
ListItem listItem = file.ListItemAllFields;
listItem["Created"] = info.SourceFile.CreationTime;
listItem["Modified"] = info.SourceFile.LastWriteTime;
MapMembers(listItem, info.MetaData);
listItem.Update();
listItem.SystemUpdate / Update(false)在Client ObjectModel中不可用。
由于
答案 0 :(得分:7)
Microsoft.SharePoint.Client.File lp_newFile = lp_web.GetFileByServerRelativeUrl(lp_uri.LocalPath);
lp_context.Load(lp_newFile);
lp_context.ExecuteQuery();
//check out to make sure not to create multiple versions
lp_newFile.CheckOut();
ListItem lp_item = lp_newFile.ListItemAllFields;
listItem["Created"] = info.SourceFile.CreationTime;
listItem["Modified"] = info.SourceFile.LastWriteTime;
listItem.Update();
// use OverwriteCheckIn type to make sure not to create multiple versions
lp_newFile.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);