从 aspx 页面读取 FileStream
我使用客户端 OM 从 SharePoint 2010 检索文档。我可以使用
var spFileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(<SPContext>, <documentPath>);
This return a type ConnectStream 检索文档。然后,我将 ConnectStream 传输到 FileStream 中,如下所示:
using (var fs = new FileStream(<documentName> + ".pdf", FileMode.OpenOrCreate))
{
spFileInfo.Stream.CopyTo(fs);
}
这确实会将物理文件写入本地文件系统,但我希望将来避免这种情况。现在我的代码隐藏中有一个 PDF 文档的 FileStream。我还有一个 UserControl 来在 aspx 页面中显示 PDF。从 UserControl 的代码隐藏中接受文件路径,如下所示:
<userControlName>.FilePath = <url>;
有没有办法将 fs 对象链接到 UserControl 的文件路径?
如果需要更多详细信息,请告诉我,谢谢。
I retrieving a document from SharePoint 2010 using the Client OM. I'm able to retrieve the document using
var spFileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(<SPContext>, <documentPath>);
This return a type ConnectStream. I'm then transferring the ConnectStream into a FileStream like so:
using (var fs = new FileStream(<documentName> + ".pdf", FileMode.OpenOrCreate))
{
spFileInfo.Stream.CopyTo(fs);
}
This does write a physical file to the local file system, but I'm hoping to avoid this in the future. Now I have a FileStream of a PDF document in my codebehind. I also have a UserControl to display PDF in the aspx page. From the codebehind the UserControl accepts the file path like so:
<userControlName>.FilePath = <url>;
Is there a way to link the fs object to the file path for the UserControl?
Please let me know if more detail is needed,Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想传递流对象,那么你必须在 UserControl 中创建一个
Stream
类型的公共属性。在
UserControl
中定义属性,并从UserControl的主机(.aspx或.ascx)的代码隐藏中分配流对象的引用。
If you want to pass stream object then you have to create a public property of
Stream
type in UserControl.Define the property in
UserControl
,and assign the reference of stream object from within the code-behind of host (.aspx or .ascx) of UserControl.