I am working on SharePoint 2010.I have an documentlibrary ID and document ID in that library with me.i don't have either web,site in which the document library is present.So now I have to get the Full URL of the document at runtime.How can I get it . I have tried the following.
string filepath = currentList.DefaultViewUrl + "/" + sListItem.Url;
Please answer this.
Use below code to get absolute URL of file:
The built in field id is for sure the best way to go but it returns the Url as encoded which may or may not be what you want.
I think the best way is to add a little extension method to a utilities class somewhere:
And then call as follows
if you want a decoded Url or
if you want the Url to remain encoded.
Note that the default parameter value for Decode will only be available in .Net4+ and therefore SP2013 only but you can easily create an overload method for SP2010. You'll also need a reference to Microsoft.SharePoint.Utilities namespace to access the SPEncode class.
The answer is string url = currentweb.url+"/"+ Listitem.url;
Use the field "EncodedAbsUrl" on the
SPListItem
. Works forSPFile
as well:or for a
SPFile
It's Working for me. Hope I help (List Item url)
Try this ,
Hope this shall get you going.