SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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
up vote 4 down vote accepted
using (SPSite site = new SPSite(<siteUrl>)
  using (SPWeb web = site.OpenWeb())
    SPList list = web.GetList(<imageUrl>);
    SPListTemplateType templateType = list.BaseTemplate;       
    int templateTypeInt = (int) templateType;
share|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 posting your answer, you agree to the privacy policy and terms of service.

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