I refer several blogs for this issue , they said there will be a column named as EncodedAbsUrl for the document set but I can't find that column.

How can I get the URI to the document?

1 Answer 1


With client object model use :

string server = site Url ;
            var context = new ClientContext(server);
            var web = context.Web;
            List list = web.Lists.GetByTitle("text");
            ListItemCollection objListItemCollection = list.GetItems(new CamlQuery());
items => items.Include(item => item.Id,
item => item["FileLeafRef"],
item => item["LinkFilename"],
item => item["FileRef"],
item => item["EncodedAbsUrl"],
item => item["DocIcon"]));


            foreach(ListItem item in objListItemCollection)
                string fileUrl = item["EncodedAbsUrl"].ToString();


You can modify the code as per your requirement.

You can get the absolute URL with the following code in server object model

SPListItem item = your item;
string absUrl = (string) item[SPBuiltInFieldId.EncodedAbsUrl];

For SPFile object:

SPFile file = your file object;
 string absUrl = (string) file.Item[SPBuiltInFieldId.EncodedAbsUrl];

Also check: https://stackoverflow.com/questions/5216832/how-to-get-the-absolute-url-of-a-file-in-sharepoint-library

  • using Client object model C# code i required that url.
    – user27178
    May 28, 2014 at 7:13
  • I am having a requirement to retrieve the document(excel doc) from the Document lib and convert it into pdf format, for that i am having the conversion code but requires the absUrl of the document.
    – user27178
    May 28, 2014 at 7:15
  • I have added the code with CSOM also. Please verfiy.
    – Aanchal
    May 28, 2014 at 7:24
  • item => item["EncodedAbsUrl"] is not available in the listItem
    – user27178
    May 28, 2014 at 9:48
  • this is code is working fine for me. Which version are you using? You can check other properties also.
    – Aanchal
    May 28, 2014 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.