在Sharepoint中显示文档 [英] Display document in Sharepoint

查看:102
本文介绍了在Sharepoint中显示文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用gridview内的链接按钮根据其单击的链接重定向到sharepoint中的特定文档.代码如下:

I''m trying to use a link button inside of a gridview to redirect to a specific document in sharepoint based on what link they click. the code is as follows:

site = new SPSite("https://c27ipacpndl103w/intranet.manpower...").openweb();
spfolder folder = site.getfolder("https://c27ipacpndl103w/intranet.manpower...");
spfile file = site.getfile("https://c27ipacpndl103w/intranet.manpower...");
response.redirect(file.url);


出于安全原因,我已经省略了一些信息,但是在spsite上,我具有包含该文件文件夹的基础站点文档库.在spfolder中,我有该文件夹的url,而spfile是该文档的几乎完全相同的url(保存为通配符的形式是这样的:


understand for security reasons I''ve left out some information but on the spsite I have the base site document library that contains the folder for the file. in spfolder, I have the url for the folder, and spfile is the near exact url for the document (save for a wild card near the end which is built like this:

spfile file = site.getfile("https://c27ipacpndl103w/intranet.manpower..." ... + udyear + "*.pdf");


"*"是通配符,因为在没有几百行代码的情况下,pdf的最后一部分是不确定的.对于此问题的任何帮助将不胜感激,如果需要更多信息,请告诉我.谢谢.

我认为问题很明显,但我会讲清楚.
如何以编程方式在sharepoint中打开文件?我不断收到未找到的url错误,我已经比较了url,它们完全相同,只是它在URL末尾加上了"*".


the "*" is a wild card because the very last part before pdf is indeterminable without a few more hundred lines of code) any assistance with this issue would be greatly appreciated and if any more information is required, please let me know. thank you.

I think it is obvious what the question is but I''ll spell it out.
How do I programmatically open a file in sharepoint? I keep getting a url not found error and I''ve compared the url''s and they are exactly the same except the end it puts the "*" in the url.

推荐答案

您在哪里尝试使用此代码?哪一行引发异常?我想这是第一行,但请确认.

在尝试时,GetFile使用相对URL而不是绝对URL.另外,您应该正确放置对象.
Where are you trying to use this code? Which line is throwing the exception? I would guess it is the very first line but please confirm.

GetFile takes a relative url not an absolute as you are trying. Also, you should be properly disposing your objects.


这篇关于在Sharepoint中显示文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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