If you need to find list item by url, there is easy way. You can create site based on file url. Than it is enough to run
GetFile which will return
SPFile object. Last thing is to get
Item object from returned file object. No need to write CALM queries.
using (SPSite siteCollecion = new SPSite(fileUrl))
{
SPWeb web = siteCollecion.RootWeb;
SPFile file = web.GetFile(fileUrl);
SPListItem listItem = file.Item;
}
Just five lines of code. Simple as that :)
Happy SharePointing ;)
No comments:
Post a Comment