Getting SharePoint objects (spweb, splist, splistitem) from url string

You basically get anything in the object model with one full url:

 1 //here is the site for the url
 2 using (SPSite site = new SPSite("http://basesmcdev2/sites/tester1/tester4/A0805051340564172608.txt"))
 3 {
 4        //here is the web for the url
 5        using (SPWeb web = site.OpenWeb())
 6        {
 7               //here is the file for the url
 8               SPFile file = web.GetFile("http://basesmcdev2/sites/tester1/tester4/A0805051340564172608.txt");
 9  
10               //here is the list for the url
11               SPList list = file.Item.ListItems.List;
12  
13               //here is the list item for the url
14               SPListItem item = file.Item;
15        }
17 } 

 

posted @ 2015-05-28 22:47  KenmuHuang  阅读(194)  评论(0编辑  收藏  举报
如果您看完本篇博文,觉得对您有所收获,请点击右下角的 [推荐]
如果您想转载,请注明出处(原创内容,请尊重个人劳动成果)
如果您有任何意见或建议,欢迎留言
感谢您的阅读,敬请关注我的后续博客文章