开发者

Sharepoint 2010: Programmatically access a documents metadata via a link

开发者 https://www.devze.com 2023-04-08 13:15 出处:网络
Is it possible to (in code) access the metadata of a document stored in a library开发者_运维百科 via a link to that document?Get SPFile object using the SPWeb.GetFile method, then use the Item propert

Is it possible to (in code) access the metadata of a document stored in a library开发者_运维百科 via a link to that document?


Get SPFile object using the SPWeb.GetFile method, then use the Item property of that object to get access to the ListItem accompanying the file.

using(SPSite site = new SPSite(link))
{
  using(SPWeb web = site.OpenWeb())
  {
   SPFile file = web.GetFile(link);
   SPListItem item = file.Item;

   object fieldValue = item["some field"];
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号