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.
For what it's worth, accessing the
item.Web
property means you are actually instantiating theSPWeb
object which means that this should be disposed otherwise you'll be causing memory leakage.It's a lot of overhead when there are better and quicker ways already mentioned.
I would use the
BuiltInFieldId.EncodedAbsUrl
approach mentioned since this gives you the easiest access to what you want.If this is for the document library, try this one.