Question

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.

Was it helpful?

Solution

using (SPSite site = new SPSite(<siteUrl>)
{
  using (SPWeb web = site.OpenWeb())
  {
    SPList list = web.GetList(<imageUrl>);
    SPListTemplateType templateType = list.BaseTemplate;       
    int templateTypeInt = (int) templateType;
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top