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"];
}
}
精彩评论