首先,我是 C# 和 SharePoint 的新手(不到一个月的经验),所以如果这是一个明显或简单的问题,我深表歉意,但我已经在网上搜索了几天,但完全没有成功。
我有一个 xslt 文件,已存储在新网站中“样式库”的子目录中,但如何从 c# 中访问该文件?
我查看过 SPSite 和 SPWeb,但似乎都无法满足我的要求。
任何和所有的帮助将不胜感激。
非常感谢
c#newbie
Firstly, I'm a newbie to C# and SharePoint, (less than a month's experience) so apologies if this is an obvious or easy question but I've been trawling the net for a couple of days now with absolutely no success.
I have an xslt file that I have stored in a subdirectory of 'Style Library' from within the new website but how can I access this from within c#?
I've looked at SPSite and SPWeb but neither seems able to do quite what I want.
Any and all help will be gratefully received.
Many thanks
c#newbie
发布评论
评论(5)
以下是从列表中检索列表项的一些代码:
要检索文件,您还可以在 SPWeb 上使用此方法: GetFileAsString
Here is a bit of code to retrieve the list items from a list:
To retrieve a file you could also use this method on SPWeb: GetFileAsString
Patrick,
我希望您喜欢 C# 和 SharePoint!
查看文章 此处。
仔细阅读该内容,它应该会为您提供所需的所有帮助。
缺口。
Patrick,
I hope you enjoy both C# and SharePoint!
Check out the article here.
Read that through, and it should give you all the assistance you need.
Nick.
不使用 linq:
可以通过多种方式检索 SPWeb,如果从 SharePoint 调用代码,则可以使用 SPContext。 要从 URL 获取 SPWeb 对象,您可以使用 SPSite 对象,即
“using”语句通过在相关对象上调用“Dispose()”来确保及时回收非托管资源。
哈特哈,
杰特
without linq:
The SPWeb can be retrieved in numerous ways, using the SPContext will work if the code is called from SharePoint. To get an SPWeb object from a URL you can use SPSite object i.e.
the 'using' statement ensures non-managed resources are reclaimed in a timely manner, by calling 'Dispose()' on the relevant objects.
HTH,
jt
尽管这可能很有效,但您应该真正研究最佳实践,因为它们与将文档存储在 12 个配置单元与内容数据库中相关。
在选择旅鼠路线之前,应该考虑更多可扩展的答案。
Effective as that may be, you should really look into best practices as they relate to storing documents in the 12 hive versus the content database.
There are much more scalable answers, which should be considered before you choose the lemming route.
非常感谢您对此的协助。 我使用了其中的一些内容并进行了一些额外的阅读,并得出了以下结论:
Many thanks for your assistance with this. I've used a little bit from each and done some additional reading and have come up with the following: