Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
add comment

1 Answer 1

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: bwaretech.com/en/Community/Team_Blog/EntryId/12/… –  Toni Frankola Nov 2 '10 at 0:33
    
Nice article. Good Luck to you! –  Ashish Patel Nov 2 '10 at 1:13
add comment

Your Answer

 
discard

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.