Programmatically get ListItemVersion using client object model SharePoint 2010

牧云@^-^@ 提交于 2019-12-03 13:11:49
Stan

You have to initialize web.ServerRelativeUrl like this

oldVersions = clientContext.LoadQuery(versions.Where(v => v != null));
clientContext.Load(web, w => w.ServerRelativeUrl);
clientContext.ExecuteQuery();

you can get older version file like this

string versionItemUrl = file.ServerRelativeUrl.Replace(Path.GetFileName(file.ServerRelativeUrl),"") + _version.Url;
File oldFile = web.GetFileByServerRelativeUrl(versionItemUrl); clientContext.Load(oldFile, f=>f.ListItemAllFields);
clientContext.ExecuteQuery();

You should be able to get the list item data using SPFileVersion.Properties which will give you a hashtable of the file's metedata see MSDN - SPFileVersion.Properties Property.

Inside your foreach try

Hashtable oHash = oFileVersion.Properties;
ICollection collKeys = oHash.Keys;

foreach (object oKey in collKeys)
{
    Console.WriteLine(oKey.ToString() + " :: " + oHash[oKey.ToString()].ToString());
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!