Tag Archives: icon-file-type

Get icon for different file types SharePoint2010

If you are working in custom search and your search result in returning various file types like

html, pdf, excel or word etc. and you want to show a small icon for corresponding file types then this article will help you.

This function will take parameter as the itemURL and it will return corresponding icon URL. MapToIcon function of SPUtility class will give us the iconURL.


private string GetIconURL(string itemURL)
{
string iconURL = string.Empty;

iconUrl = “/_layouts/images/” + SPUtility.MapToIcon(SPContext.Current.Web, itemURL, string.Empty, IconSize.Size16);

return iconURL;
}

Advertisements