我有一个存储在sharepoint的doc库中的文件..现在我想打开并从中读取数据......我怎么能这样做..filestream不会将url作为输入..请帮助。< / p>
答案 0 :(得分:1)
来自SharePoint 2007 - Read content from SPFile:
string content = string.Empty;
using (SPSite oSite = new SPSite("http://localhost/"))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPDocumentLibrary doclib = (SPDocumentLibrary)oWeb.GetList(DocLibUrl);
SPFile htmlFile = doclib.Items[0].File;
using (System.IO.StreamReader reader = new System.IO.StreamReader(htmlFile.OpenBinaryStream()))
{
content = reader.ReadToEnd();
}
}
}
答案 1 :(得分:0)
听起来您需要使用HTTPRequest对象来检索文件。这是一个代码示例:
http://geeknotes.wordpress.com/2008/01/10/saving-a-possibly-binary-file-from-a-url-in-c/