如何在Sharepoint库中获取文件的绝对URL [英] How to get the Absolute URL of a file in sharepoint library

查看:454
本文介绍了如何在Sharepoint库中获取文件的绝对URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SharePoint2010.我在该库中有一个文档库ID和文档ID.我没有一个存在文档库的网站,因此现在我必须获取完整URL在运行时文档的文件.我该如何获取它. 我尝试了以下方法.

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;

请回答.

推荐答案

使用SPListItem上的字段"EncodedAbsUrl".也适用于SPFile:

Use the field "EncodedAbsUrl" on the SPListItem. Works for SPFile as well:

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

SPFile

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

这篇关于如何在Sharepoint库中获取文件的绝对URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆