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

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

问题描述

我正在研究 SharePoint 2010.我在该库中有一个文档库 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];

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

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