我正在尝试使用 MVC 从 SharePoint 文档库下载文档,但是每当我尝试运行我的代码时,都会出现上述错误。我是 SharePoint 的新手,所以请善待。这是我的代码:
网络助手:
public Stream DownloadDocument(string SiteURL, string documentName)
{
ListItem item = GetDocumentFromSP(documentName);
if (item != null) {
using (ClientContext clientContext = new ClientContext(SiteUrl)) {
FileInformation fileInformation =
Microsoft.SharePoint.Client.File.OpenBinaryDirect(
clientContext,
item["My Document.docx"].ToString()
);
return fileInformation.Stream;
}
}
return null;
}
控制器:
public ActionResult Index()
{
Stream documentDownload =
WebHelper.DownloadDocument(
"http://MySharePointServer/Docs/Forms/AllItems.aspx",
"My Document"
);
model.downloadedDoc = documentDownload;
return view(model)
}