2

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

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()); context.Load(objListItemCollection, items => items.Include(item => item.Id, item => item["FileLeafRef"], item => item["LinkFilename"], item => item["FileRef"], item => item["EncodedAbsUrl"], item => item["DocIcon"])); context.ExecuteQuery(); 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

5
  • using Client object model C# code i required that url. Commented 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. Commented May 28, 2014 at 7:15
  • I have added the code with CSOM also. Please verfiy. Commented May 28, 2014 at 7:24
  • item => item["EncodedAbsUrl"] is not available in the listItem Commented 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. Commented May 28, 2014 at 9:53

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.