4

Imagine if you have image url which is existing within a site collection in Sitecollectionimages library: testserver/Sitecollectionimages/image.jpg

How can I get the TemplateType (which kind of library is this for e.g. Type 109 is for Picture Library) of this library using the image url?

Update: I will always have an absolute URL of the image.

  • Is this image url an absolute url? – Matthias May 24 '12 at 11:16
  • why dont use, SP solution generator and see the lists and document library associated to that specific site/sitecollection :) – Muhammad Raja May 24 '12 at 12:05
  • Matthias, it will always be be an absolute url – Geek May 24 '12 at 12:35
4
using (SPSite site = new SPSite(<siteUrl>)
{
  using (SPWeb web = site.OpenWeb())
  {
    SPList list = web.GetList(<imageUrl>);
    SPListTemplateType templateType = list.BaseTemplate;       
    int templateTypeInt = (int) templateType;
  }
}
| improve this answer | |
  • Mathias, will it work for absolute url? – Geek May 24 '12 at 12:41
  • will it work for image url like this ? testserver/Sitecollectionimages/image.jpg – Geek May 24 '12 at 22:57
  • +1, it should work as expected – Falak Mahmood May 24 '12 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.