有什么方法可以使用 c# 获取共享点文档的自定义 column/property 值吗?
Is there any way to get custom column/property value of sharepoint document using c#?
下面的代码工作正常,并为我提供了进入 Sharepoint 站点的所有文件列表。
我得到文件的标准属性,如 item.File.Author and item.File.ModifiedBy but not custom item.File.Location
// Sharepoint Object Model Code
ClientContext clientContext = new ClientContext("siteurl");
clientContext.Credentials = new NetworkCredential("username","password");
Web web = clientContext.Web;
clientContext.Load(web);
clientContext.Load(web.Lists);
clientContext.Load(web, wb => wb.ServerRelativeUrl);
clientContext.ExecuteQuery();
List list = web.Lists.GetByTitle("My Doc");
clientContext.Load(list);
clientContext.ExecuteQuery();
Folder folder = web.GetFolderByServerRelativeUrl(web.ServerRelativeUrl + @"My Doc");
clientContext.Load(folder);
clientContext.ExecuteQuery();
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = @"<View Scope='RecursiveAll'>
<Query>
</Query>
</View>";
camlQuery.FolderServerRelativeUrl = folder.ServerRelativeUrl;
ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
FileInformation fileInfo;
foreach (var item in listItems)
{
// How to get File custom properties ? i.e Location , Path , Flat
// I can get standard properties of file like -
// item.File.Author and item.File.ModifiedBy but not item.File.Location
要获得"Location","Path"值,我们需要使用下面的代码:
var location=item["Location"];
var path=item["Path"];
下面的代码工作正常,并为我提供了进入 Sharepoint 站点的所有文件列表。
我得到文件的标准属性,如 item.File.Author and item.File.ModifiedBy but not custom item.File.Location
// Sharepoint Object Model Code
ClientContext clientContext = new ClientContext("siteurl");
clientContext.Credentials = new NetworkCredential("username","password");
Web web = clientContext.Web;
clientContext.Load(web);
clientContext.Load(web.Lists);
clientContext.Load(web, wb => wb.ServerRelativeUrl);
clientContext.ExecuteQuery();
List list = web.Lists.GetByTitle("My Doc");
clientContext.Load(list);
clientContext.ExecuteQuery();
Folder folder = web.GetFolderByServerRelativeUrl(web.ServerRelativeUrl + @"My Doc");
clientContext.Load(folder);
clientContext.ExecuteQuery();
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = @"<View Scope='RecursiveAll'>
<Query>
</Query>
</View>";
camlQuery.FolderServerRelativeUrl = folder.ServerRelativeUrl;
ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
FileInformation fileInfo;
foreach (var item in listItems)
{
// How to get File custom properties ? i.e Location , Path , Flat
// I can get standard properties of file like -
// item.File.Author and item.File.ModifiedBy but not item.File.Location
要获得"Location","Path"值,我们需要使用下面的代码:
var location=item["Location"];
var path=item["Path"];