Thursday, October 7, 2010

SharePoint: How to get document icon image

There is a method in SPUtility which makes it much easier. It takes image file name from docicon.xml, and should work Ok even if the file name is not follow the pattern ic{doc ext}.gif

string docIcon = SPUtility.ConcatUrls("/_layouts/images/",
SPUtility.ConcatUrls(item.Web.Url,item.Url), "", IconSize.Size16));

There is a good post about SPUtility.MapToIcon vs SPFile.GetIcon

No comments:

Post a Comment