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

This article explains how you can configure icons for files in SharePoint. But what if you want to reuse these icons for custom links that your solution (e.g. webpart) generates. Is there a smart and easy way to read these Mappings to determine icon for each URL pointing to a file?

share|improve this question
up vote 3 down vote accepted

Yes, it is possible and an API exists to help you!

SPUtility's following method can retrieve the value of the icon for the file (or file extension) that you specify in input parameter.

public static string MapToIcon(
    SPWeb web,
    string strFileName,
    string strProgID,
    IconSize size

Notes: 1. The returned value is based on the mapping between file extension and corresponding icon that exists in {SharePointRoot}\TEMPLATE\XML\DOCICON.XML

  1. Icon needs to be present in {SharePointRoot}\Template\Images folder

The value that you might be interested would be /_layout/images/[Returned Value of above function]

share|improve this answer
Huh, now that you mentioned that, I also fond this nice article about that:… – Toni Frankola Nov 2 '10 at 0:33
Nice article. Good Luck to you! – Ashish Patel Nov 2 '10 at 1:13

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.