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

How to get attachment full URL programmatically From SharePoint list item?


I have adding new item with attachment. Now I have to bind that attachment link to grid. When click on that link Attachment should be open.

How can I get Attachment URL of that item?

share|improve this question
up vote 5 down vote accepted

I found answer for my question.

private string GetAttachmentUrls(SPListItem oItem)

        string path = string.Empty;



            path = (from string file in oItem.Attachments
                              orderby file
                              select SPUrlUtility.CombineUrl(oItem.Attachments.UrlPrefix, file)).FirstOrDefault();
            return path;
            return string.Empty;

share|improve this answer
can you please give a bit explanation of this code? – Ma6139735 Jun 16 at 12:22

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.